diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5eb8c86 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +# Automatically build the project and run any configured tests for every push +# and submitted pull request. This can help catch issues that only occur on +# certain platforms or Java versions, and provides a first line of defence +# against bad commits. + +name: build +on: [pull_request, push] + +jobs: + build: + strategy: + matrix: + # Use these Java versions + java: [ + 17, # Current Java LTS & minimum supported by Minecraft + 21, # Current Java LTS + ] + # and run on both Linux and Windows + os: [ubuntu-22.04, windows-2022] + runs-on: ${{ matrix.os }} + steps: + - name: checkout repository + uses: actions/checkout@v4 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: 'microsoft' + - name: make gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: build + run: ./gradlew build + - name: capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: build/libs/ \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index dd80175..1dea5e8 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -14,10 +14,10 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' + java-version: '21' distribution: 'adopt' - name: Change wrapper permissions run: chmod +x ./gradlew @@ -30,16 +30,17 @@ jobs: if: endswith(github.ref_name, 'master') && github.ref_protected && github.ref_type == 'branch' runs-on: ubuntu-latest env: - APPVEYOR_BUILD_VERSION: '3.2.2' + APPVEYOR_BUILD_VERSION: '3.2.3' CURSETOKEN: ${{ secrets.CURSETOKEN }} + MODRINTHTOKEN: ${{ secrets.MODRINTHTOKEN }} steps: - uses: actions/checkout@v3 with: submodules: true - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' + java-version: '21' distribution: 'adopt' - name: Change wrapper permissions run: chmod +x ./gradlew diff --git a/.gitignore b/.gitignore index 12f8644..9746858 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ build # other eclipse run +runs # Files from Forge MDK forge*changelog.txt diff --git a/.gitmodules b/.gitmodules index 83f69b0..a5dc8cb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "linkableapi"] path = linkableapi url = https://github.com/MrTroble/linkableapi + branch = 1.21.3-fabric diff --git a/build.gradle b/build.gradle index 3b105e4..379839d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,20 +1,18 @@ -buildscript { - repositories { - maven { url = 'https://files.minecraftforge.net/maven' } - maven { url "https://plugins.gradle.org/m2/" } - jcenter() - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.0.+', changing: true - classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.4.0" - } +plugins { + id 'fabric-loom' version '1.11-SNAPSHOT' + id 'maven-publish' + id "com.matthewprenger.cursegradle" version "1.4.0" + id "com.modrinth.minotaur" version "2.+" +} + +def ver = System.getenv("APPVEYOR_BUILD_VERSION") +if(ver == null) + ver = "dev" +version = ver +group = 'com.troblecodings' +base { + archivesName = 'TC-Redstone-1.21.4-Fabric' } - -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' -apply plugin: 'maven-publish' -apply plugin: "com.matthewprenger.cursegradle" sourceSets{ main { @@ -28,88 +26,89 @@ def key = System.getenv("CURSETOKEN") if(key == null) key = 'dev' curseforge { - apiKey = key - project { - id = '503143' - changelog = file('changelog.md') - changelogType = 'markdown' - releaseType = 'release' - addGameVersion 'Java 17' - } + apiKey = key + project { + id = '503143' + changelog = file('changelog.md') + changelogType = 'markdown' + releaseType = 'release' + addGameVersion 'Java 21' + mainArtifact(remapJar) { + displayName = "Example $project.version" + } + } + options { + forgeGradleIntegration = false + } } +afterEvaluate { + tasks.curseforge503143.dependsOn remapJar +} -def ver = System.getenv("APPVEYOR_BUILD_VERSION") -if(ver == null) - ver = "dev" -version = ver -group = 'com.troblecodings' -archivesBaseName = 'TC-Redstone-1.20.1' - -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -minecraft { - mappings channel: 'official', version: '1.20.1' - - runs { - client { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - - mods { - gircredstone { - source sourceSets.main - } - } - } - server { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - - mods { - gircredstone { - source sourceSets.main - } - } - } - } +def token = System.getenv("MODRINTHTOKEN") +if(token == null) + token = 'dev' +modrinth { + token = token + projectId = 'rMlghquR' + versionNumber = ver + versionType = 'release' + versionName = 'TC-Redstone-1.21.4-Fabric' + uploadFile = remapJar + gameVersions = ['1.21.4'] + loaders = ['fabric'] } -repositories { - +task publishToModSites { + publishToModSites.dependsOn modrinth + publishToModSites.dependsOn curseforge } dependencies { - minecraft 'net.minecraftforge:forge:1.20.1-47.2.0' + minecraft "com.mojang:minecraft:${minecraft_version}" + mappings "net.fabricmc:yarn:${yarn_mappings}" + modImplementation "net.fabricmc:fabric-loader:${loader_version}" + + modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}" +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 21 +} + +java { + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { - manifest { - attributes([ - "Specification-Title": "TC-Redstone", - "Specification-Vendor": "troblecodings", - "Specification-Version": ver, - "Implementation-Title": project.name, - "Implementation-Version": ver, - "Implementation-Vendor" :"troblecodings", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } + from("LICENSE") { + rename { "${it}_${project.base.archivesName.get()}"} + } } -jar.finalizedBy('reobfJar') publishing { - publications { - mavenJava(MavenPublication) { - artifact jar - } - } - repositories { - maven { + publications { + mavenJava(MavenPublication) { + from components.java + } + } + + repositories { + maven { url "file:///${project.projectDir}/mcmodsrepo" } - } -} + } +} \ No newline at end of file diff --git a/changelog.md b/changelog.md index 6072f17..9e50954 100644 --- a/changelog.md +++ b/changelog.md @@ -1,8 +1,12 @@ # Changelog -## [1.20.1 - 3.2.2] +## [1.21 Fabric - 3.2.3] -* rem: debug output +* port to 1.21 + +## [1.20.4 Fabric - 3.2.3] + +* port to fabric ## [1.20.1-3.2.1] diff --git a/gradle.properties b/gradle.properties index 878bf1f..1b44add 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,18 @@ -# Sets default memory used for gradle commands. Can be overridden by user or command line properties. -# This is required to provide enough memory for the Minecraft decompilation process. -org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false \ No newline at end of file +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +# Fabric Properties +# check these on https://fabricmc.net/develop +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.8 +loader_version=0.16.14 +loom_version=1.11-SNAPSHOT + +# Mod Properties +mod_version=1.0.0 +maven_group=com.example +archives_base_name=modid + +# Dependencies +fabric_version=0.119.4+1.21.4 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..1b33c55 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fae0804..ff23a68 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index c53aefa..23d15a9 100644 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -32,10 +34,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -133,22 +133,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,18 +200,28 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd3..db3a6ac 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,32 +59,34 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/linkableapi b/linkableapi index 46583ac..8ee288c 160000 --- a/linkableapi +++ b/linkableapi @@ -1 +1 @@ -Subproject commit 46583ac0aa18f98cfd2fb38e18064e3586e54c4b +Subproject commit 8ee288ce3080bcab2fd1b559856739fd4d993c91 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..75c4d72 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/tcredstone/GIRCRedstoneMain.java b/src/main/java/com/troblecodings/tcredstone/GIRCRedstoneMain.java deleted file mode 100644 index 17cd0f4..0000000 --- a/src/main/java/com/troblecodings/tcredstone/GIRCRedstoneMain.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.troblecodings.tcredstone; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.troblecodings.tcredstone.init.GIRCInit; - -import net.minecraftforge.fml.common.Mod; - -@Mod(GIRCRedstoneMain.MODID) -public class GIRCRedstoneMain { - - public GIRCRedstoneMain() { - GIRCInit.init(); - } - - public static final Logger LOGGER = LogManager.getLogger(); - - public static final String MODID = "gircredstone"; - -} diff --git a/src/main/java/com/troblecodings/tcredstone/TCRedstoneMain.java b/src/main/java/com/troblecodings/tcredstone/TCRedstoneMain.java new file mode 100644 index 0000000..80a6dc2 --- /dev/null +++ b/src/main/java/com/troblecodings/tcredstone/TCRedstoneMain.java @@ -0,0 +1,27 @@ +package com.troblecodings.tcredstone; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.troblecodings.tcredstone.init.TCInit; + +import net.fabricmc.api.ModInitializer; +import net.minecraft.component.ComponentType; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.network.codec.PacketCodecs; + +public class TCRedstoneMain implements ModInitializer { + + public static final ComponentType COMPOUND_DATA = + ComponentType.builder().codec(NbtCompound.CODEC) + .packetCodec(PacketCodecs.NBT_COMPOUND).build(); + + public static final String MODID = "tcredstone"; + public static final Logger LOGGER = LogManager.getLogger(); + + @Override + public void onInitialize() { + TCInit.init(); + TCInit.registerDataComponents(); + } +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneAcceptor.java b/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneAcceptor.java index 3307587..88a9bc5 100644 --- a/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneAcceptor.java +++ b/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneAcceptor.java @@ -1,42 +1,42 @@ package com.troblecodings.tcredstone.block; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition.Builder; -import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.state.StateManager.Builder; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; public class BlockRedstoneAcceptor extends Block { - public static final BooleanProperty POWER = BooleanProperty.create("power"); - - public BlockRedstoneAcceptor(final Properties properties) { - super(properties); - this.registerDefaultState(this.defaultBlockState().setValue(POWER, false)); - } - - @Override - public boolean isSignalSource(final BlockState blockState) { - return true; - } - - @Override - public int getSignal(final BlockState blockState, final BlockGetter world, final BlockPos pos, - final Direction direction) { - return this.getDirectSignal(blockState, world, pos, direction); - } - - @Override - public int getDirectSignal(final BlockState blockState, final BlockGetter world, - final BlockPos pos, final Direction direction) { - return blockState.getValue(POWER) ? 15 : 0; - } - - @Override - protected void createBlockStateDefinition(final Builder builder) { - builder.add(POWER); - } + public static final BooleanProperty POWER = BooleanProperty.of("power"); + + public BlockRedstoneAcceptor(final Settings properties) { + super(properties); + this.setDefaultState(this.getDefaultState().with(POWER, false)); + } + + @Override + public boolean emitsRedstonePower(final BlockState blockState) { + return true; + } + + @Override + public int getStrongRedstonePower(final BlockState blockState, final BlockView world, final BlockPos pos, + final Direction direction) { + return this.getWeakRedstonePower(blockState, world, pos, direction); + } + + @Override + public int getWeakRedstonePower(final BlockState blockState, final BlockView world, final BlockPos pos, + final Direction direction) { + return blockState.get(POWER) ? 15 : 0; + } + + @Override + protected void appendProperties(final Builder builder) { + builder.add(POWER); + } } diff --git a/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneEmitter.java b/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneEmitter.java index 4d69a91..d79d2e8 100644 --- a/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneEmitter.java +++ b/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneEmitter.java @@ -1,33 +1,37 @@ package com.troblecodings.tcredstone.block; import com.troblecodings.linkableapi.Message; -import com.troblecodings.tcredstone.init.GIRCInit; +import com.troblecodings.tcredstone.init.TCInit; import com.troblecodings.tcredstone.tile.TileRedstoneEmitter; -import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.EntityBlock; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.block.Block; +import net.minecraft.block.BlockEntityProvider; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.block.WireOrientation; -public class BlockRedstoneEmitter extends Block implements EntityBlock, Message { +public class BlockRedstoneEmitter extends Block implements BlockEntityProvider, Message { - public BlockRedstoneEmitter(final Properties properties) { + public BlockRedstoneEmitter(final Settings properties) { super(properties); } @Override - public InteractionResult use(final BlockState state, final Level world, final BlockPos pos, - final Player player, final InteractionHand hand, final BlockHitResult hit) { - if (world.isClientSide) - return InteractionResult.PASS; - if (player.getItemInHand(hand).getItem().equals(GIRCInit.RS_LINKER.get())) - return InteractionResult.PASS; + protected ActionResult onUseWithItem(final ItemStack stack, final BlockState state, + final World world, final BlockPos pos, final PlayerEntity player, final Hand hand, + final BlockHitResult hit) { + if (world.isClient()) + return ActionResult.PASS_TO_DEFAULT_BLOCK_ACTION; + if (player.getStackInHand(hand).getItem().equals(TCInit.RS_LINKER) + || player.getStackInHand(hand).getItem().equals(TCInit.RS_MULTILINKER)) + return ActionResult.PASS_TO_DEFAULT_BLOCK_ACTION; final BlockEntity entity = world.getBlockEntity(pos); if (entity instanceof TileRedstoneEmitter) { final TileRedstoneEmitter emitter = (TileRedstoneEmitter) entity; @@ -35,7 +39,7 @@ public InteractionResult use(final BlockState state, final Level world, final Bl if (linkedpos == null) { message(player, "em.notlinked"); } else { - if (player.isCrouching()) { + if (player.isSneaking()) { emitter.unlink(); message(player, "em.unlink", linkedpos.getX(), linkedpos.getY(), linkedpos.getZ()); @@ -44,25 +48,25 @@ public InteractionResult use(final BlockState state, final Level world, final Bl linkedpos.getZ()); } } - return InteractionResult.SUCCESS; + return ActionResult.SUCCESS; } - return InteractionResult.FAIL; + return ActionResult.FAIL; } @Override - public void neighborChanged(final BlockState state, final Level world, final BlockPos pos, - final Block blockIn, final BlockPos fromPos, final boolean isMoving) { - if (world.isClientSide) + public void neighborUpdate(final BlockState state, final World world, final BlockPos pos, + final Block blockIn, final WireOrientation orientation, final boolean isMoving) { + if (world.isClient()) return; final BlockEntity entity = world.getBlockEntity(pos); if (entity instanceof TileRedstoneEmitter) { final TileRedstoneEmitter emitter = (TileRedstoneEmitter) entity; - emitter.redstoneUpdate(world.hasNeighborSignal(pos)); + emitter.redstoneUpdate(world.isReceivingRedstonePower(pos)); } } @Override - public BlockEntity newBlockEntity(final BlockPos pos, final BlockState state) { + public BlockEntity createBlockEntity(final BlockPos pos, final BlockState state) { return new TileRedstoneEmitter(pos, state); } diff --git a/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneMultiEmitter.java b/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneMultiEmitter.java index 88a1923..4b6a9ec 100644 --- a/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneMultiEmitter.java +++ b/src/main/java/com/troblecodings/tcredstone/block/BlockRedstoneMultiEmitter.java @@ -3,37 +3,41 @@ import java.util.List; import com.troblecodings.linkableapi.Message; -import com.troblecodings.tcredstone.init.GIRCInit; +import com.troblecodings.tcredstone.init.TCInit; import com.troblecodings.tcredstone.tile.TileRedstoneMultiEmitter; -import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.block.WireOrientation; public class BlockRedstoneMultiEmitter extends BlockRedstoneEmitter implements Message { - public BlockRedstoneMultiEmitter(final Properties properties) { + public BlockRedstoneMultiEmitter(final Settings properties) { super(properties); } @Override - public BlockEntity newBlockEntity(final BlockPos pos, final BlockState state) { + public BlockEntity createBlockEntity(final BlockPos pos, final BlockState state) { return new TileRedstoneMultiEmitter(pos, state); } @Override - public InteractionResult use(final BlockState state, final Level world, final BlockPos pos, - final Player player, final InteractionHand hand, final BlockHitResult hit) { - if (world.isClientSide) - return InteractionResult.PASS; - if (player.getItemInHand(hand).getItem().equals(GIRCInit.RS_LINKER.get())) - return InteractionResult.PASS; + protected ActionResult onUseWithItem(final ItemStack stack, final BlockState state, + final World world, final BlockPos pos, final PlayerEntity player, final Hand hand, + final BlockHitResult hit) { + if (world.isClient()) + return ActionResult.PASS_TO_DEFAULT_BLOCK_ACTION; + if (player.getStackInHand(hand).getItem().equals(TCInit.RS_LINKER) + || player.getStackInHand(hand).getItem().equals(TCInit.RS_MULTILINKER)) + return ActionResult.PASS_TO_DEFAULT_BLOCK_ACTION; final BlockEntity entity = world.getBlockEntity(pos); if (entity instanceof TileRedstoneMultiEmitter) { final TileRedstoneMultiEmitter emitter = (TileRedstoneMultiEmitter) entity; @@ -41,7 +45,7 @@ public InteractionResult use(final BlockState state, final Level world, final Bl if (listOfPositions == null) { message(player, "em.notlinked"); } else { - if (player.isCrouching()) { + if (player.isSneaking()) { emitter.unlink(); listOfPositions.forEach(blockpos -> message(player, "em.unlink", blockpos.getX(), blockpos.getY(), blockpos.getZ())); @@ -50,20 +54,20 @@ public InteractionResult use(final BlockState state, final Level world, final Bl blockpos.getX(), blockpos.getY(), blockpos.getZ())); } } - return InteractionResult.SUCCESS; + return ActionResult.SUCCESS; } - return InteractionResult.FAIL; + return ActionResult.FAIL; } @Override - public void neighborChanged(final BlockState state, final Level world, final BlockPos pos, - final Block blockIn, final BlockPos fromPos, final boolean isMoving) { - if (world.isClientSide) + public void neighborUpdate(final BlockState state, final World world, final BlockPos pos, + final Block blockIn, final WireOrientation orientation, final boolean isMoving) { + if (world.isClient()) return; final BlockEntity entity = world.getBlockEntity(pos); if (entity instanceof TileRedstoneMultiEmitter) { final TileRedstoneMultiEmitter emitter = (TileRedstoneMultiEmitter) entity; - emitter.redstoneUpdate(world.hasNeighborSignal(pos)); + emitter.redstoneUpdate(world.isReceivingRedstonePower(pos)); } } diff --git a/src/main/java/com/troblecodings/tcredstone/init/GIRCInit.java b/src/main/java/com/troblecodings/tcredstone/init/GIRCInit.java deleted file mode 100644 index e6b8be8..0000000 --- a/src/main/java/com/troblecodings/tcredstone/init/GIRCInit.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.troblecodings.tcredstone.init; - -import java.util.function.Supplier; - -import com.troblecodings.linkableapi.Linkingtool; -import com.troblecodings.linkableapi.MultiLinkingTool; -import com.troblecodings.tcredstone.GIRCRedstoneMain; -import com.troblecodings.tcredstone.block.BlockRedstoneAcceptor; -import com.troblecodings.tcredstone.block.BlockRedstoneEmitter; -import com.troblecodings.tcredstone.block.BlockRedstoneMultiEmitter; -import com.troblecodings.tcredstone.item.RemoteActivator; -import com.troblecodings.tcredstone.tile.TileRedstoneEmitter; -import com.troblecodings.tcredstone.tile.TileRedstoneMultiEmitter; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTabs; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Item.Properties; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; - -public class GIRCInit { - - public static final DeferredRegister ITEM_REGISTRY = DeferredRegister - .create(ForgeRegistries.ITEMS, GIRCRedstoneMain.MODID); - public static final DeferredRegister BLOCK_REGISTRY = DeferredRegister - .create(ForgeRegistries.BLOCKS, GIRCRedstoneMain.MODID); - public static final DeferredRegister> TILEENTITY_REGISTRY = DeferredRegister - .create(ForgeRegistries.BLOCK_ENTITY_TYPES, GIRCRedstoneMain.MODID); - - public static final RegistryObject RS_ACCEPTOR = internalRegisterBlock("acceptor", - () -> new BlockRedstoneAcceptor(BlockBehaviour.Properties.of() //TODO Material.METAL - .strength(1.5f, 6.0f).requiresCorrectToolForDrops())); - public static final RegistryObject RS_EMITTER = internalRegisterBlock("emitter", - () -> new BlockRedstoneEmitter(BlockBehaviour.Properties.of() //TODO Material.METAL - .strength(1.5f, 6.0f).requiresCorrectToolForDrops())); - public static final RegistryObject RS_MULTI_EMITTER = internalRegisterBlock( - "multiemitter", () -> new BlockRedstoneMultiEmitter(BlockBehaviour.Properties - .of().strength(1.5f, 6.0f).requiresCorrectToolForDrops())); //TODO Material.METAL - - public static boolean acceptAcceptor(final Level level, final BlockPos pos) { - return level.getBlockState(pos).getBlock() instanceof BlockRedstoneAcceptor; - } - - public static final RegistryObject RS_LINKER = ITEM_REGISTRY.register("linker", - () -> new Linkingtool(null, GIRCInit::acceptAcceptor)); - public static final RegistryObject RS_MULTILINKER = ITEM_REGISTRY.register("multilinker", - () -> new MultiLinkingTool(null, GIRCInit::acceptAcceptor)); - public static final RegistryObject REMOTE_ACTIVATOR = ITEM_REGISTRY.register("activator", - () -> new RemoteActivator()); - - public static final RegistryObject> EMITER_TILE = TILEENTITY_REGISTRY - .register("emitter", () -> BlockEntityType.Builder - .of(TileRedstoneEmitter::new, RS_EMITTER.get()).build(null)); - - public static final RegistryObject> MULTI_EMITER_TILE = TILEENTITY_REGISTRY - .register("multiemitter", () -> BlockEntityType.Builder - .of(TileRedstoneMultiEmitter::new, RS_MULTI_EMITTER.get()).build(null)); - - private static final RegistryObject internalRegisterBlock(final String name, - final Supplier sup) { - final RegistryObject registerObject = BLOCK_REGISTRY.register(name, sup); - ITEM_REGISTRY.register(name, () -> new BlockItem(registerObject.get(), new Properties())); - return registerObject; - } - - public static void init() { - final IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); - bus.register(GIRCInit.class); - ITEM_REGISTRY.register(bus); - BLOCK_REGISTRY.register(bus); - TILEENTITY_REGISTRY.register(bus); - } - - @SubscribeEvent - public static void onCreativeTabs(final BuildCreativeModeTabContentsEvent event) { - if (event.getTabKey().equals(CreativeModeTabs.REDSTONE_BLOCKS)) { - ITEM_REGISTRY.getEntries().forEach(event::accept); - } - } - -} diff --git a/src/main/java/com/troblecodings/tcredstone/init/TCInit.java b/src/main/java/com/troblecodings/tcredstone/init/TCInit.java new file mode 100644 index 0000000..4cb2029 --- /dev/null +++ b/src/main/java/com/troblecodings/tcredstone/init/TCInit.java @@ -0,0 +1,110 @@ +package com.troblecodings.tcredstone.init; + +import java.util.function.Function; + +import com.troblecodings.linkableapi.Linkingtool; +import com.troblecodings.linkableapi.MultiLinkingTool; +import com.troblecodings.tcredstone.TCRedstoneMain; +import com.troblecodings.tcredstone.block.BlockRedstoneAcceptor; +import com.troblecodings.tcredstone.block.BlockRedstoneEmitter; +import com.troblecodings.tcredstone.block.BlockRedstoneMultiEmitter; +import com.troblecodings.tcredstone.item.RemoteActivator; +import com.troblecodings.tcredstone.tile.TileRedstoneEmitter; +import com.troblecodings.tcredstone.tile.TileRedstoneMultiEmitter; + +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; +import net.minecraft.item.Item.Settings; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class TCInit { + + public static final Item RS_LINKER = registerItem("linker", + settings -> new Linkingtool(settings, null, TCInit::acceptAcceptor), + ItemGroups.REDSTONE); + public static final Item RS_MULTILINKER = registerItem("multilinker", + settings -> new MultiLinkingTool(settings, null, TCInit::acceptAcceptor), + ItemGroups.REDSTONE); + public static final Item REMOTE_ACTIVATOR = registerItem("activator", + settings -> new RemoteActivator(settings, TCInit::acceptAcceptor), ItemGroups.REDSTONE); + + public static final Block RS_ACCEPTOR = registerBlock("acceptor", + settings -> new BlockRedstoneAcceptor(settings.strength(1.5f, 6.0f)), + ItemGroups.REDSTONE); + + public static final Block RS_EMITTER = registerBlock("emitter", + settings -> new BlockRedstoneEmitter(settings.strength(1.5f, 6.0f)), + ItemGroups.REDSTONE); + + public static final Block RS_MULTI_EMITTER = registerBlock("multiemitter", + settings -> new BlockRedstoneMultiEmitter(settings.strength(1.5f, 6.0f)), + ItemGroups.REDSTONE); + + public static final BlockEntityType EMITER_TILE = Registry.register( + Registries.BLOCK_ENTITY_TYPE, Identifier.of(TCRedstoneMain.MODID, "emitter"), + FabricBlockEntityTypeBuilder + .create(TileRedstoneEmitter::new, RS_EMITTER) + .build()); + + public static final BlockEntityType MULTI_EMITER_TILE = + Registry.register(Registries.BLOCK_ENTITY_TYPE, + Identifier.of(TCRedstoneMain.MODID, "multiemitter"), + FabricBlockEntityTypeBuilder.create( + TileRedstoneMultiEmitter::new, RS_MULTI_EMITTER).build()); + + public static boolean acceptAcceptor(final World level, final BlockPos pos) { + return level.getBlockState(pos).getBlock() instanceof BlockRedstoneAcceptor; + } + + private static Block registerBlock(final String name, + final Function factory, + final RegistryKey group) { + final Identifier id = Identifier.of(TCRedstoneMain.MODID, name); + final RegistryKey blockKey = RegistryKey.of(RegistryKeys.BLOCK, id); + final Block block = factory.apply(AbstractBlock.Settings.create().registryKey(blockKey)); + registerBlockItem(name, block, group); + return Registry.register(Registries.BLOCK, blockKey, block); + } + + private static Item registerBlockItem(final String name, final Block block, + final RegistryKey group) { + final RegistryKey itemKey = + RegistryKey.of(RegistryKeys.ITEM, Identifier.of(TCRedstoneMain.MODID, name)); + final Item item = + Registry.register(Registries.ITEM, itemKey, new BlockItem(block, new Settings() + .registryKey(itemKey).useBlockPrefixedTranslationKey())); + ItemGroupEvents.modifyEntriesEvent(group).register(entries -> entries.add(item)); + return item; + } + + private static Item registerItem(final String name, final Function factory, + final RegistryKey group) { + final RegistryKey itemKey = + RegistryKey.of(RegistryKeys.ITEM, Identifier.of(TCRedstoneMain.MODID, name)); + final Item item = factory.apply(new Settings().registryKey(itemKey)); + ItemGroupEvents.modifyEntriesEvent(group).register(entries -> entries.add(item)); + return Registry.register(Registries.ITEM, itemKey, item); + } + + public static void registerDataComponents() { + Registry.register(Registries.DATA_COMPONENT_TYPE, + Identifier.of(TCRedstoneMain.MODID, "compound_data"), TCRedstoneMain.COMPOUND_DATA); + } + + public static void init() { + } + +} diff --git a/src/main/java/com/troblecodings/tcredstone/item/RemoteActivator.java b/src/main/java/com/troblecodings/tcredstone/item/RemoteActivator.java index 7136ca3..bd2086e 100644 --- a/src/main/java/com/troblecodings/tcredstone/item/RemoteActivator.java +++ b/src/main/java/com/troblecodings/tcredstone/item/RemoteActivator.java @@ -1,35 +1,42 @@ package com.troblecodings.tcredstone.item; +import java.util.Optional; +import java.util.function.BiPredicate; + import com.troblecodings.linkableapi.Linkingtool; -import com.troblecodings.tcredstone.init.GIRCInit; +import com.troblecodings.tcredstone.TCRedstoneMain; import com.troblecodings.tcredstone.tile.TileRedstoneEmitter; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtUtils; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtHelper; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; public class RemoteActivator extends Linkingtool { - public RemoteActivator() { - super(null, GIRCInit::acceptAcceptor, _u1 -> false); + public RemoteActivator(final Settings settings, final BiPredicate predicate) { + super(settings, null, predicate, _u1 -> false); } @Override - public InteractionResultHolder use(final Level level, final Player player, - final InteractionHand hand) { - final ItemStack itemstack = player.getItemInHand(hand); - if (!hand.equals(InteractionHand.MAIN_HAND) || level.isClientSide) - return InteractionResultHolder.pass(itemstack); - final CompoundTag comp = itemstack.getTag(); - final BlockPos linkpos = NbtUtils.readBlockPos(comp); - final boolean state = TileRedstoneEmitter.redstoneUpdate(linkpos, level); - message(player, "ra.state", String.valueOf(state)); - return InteractionResultHolder.success(itemstack); + public ActionResult use(final World level, final PlayerEntity player, final Hand hand) { + final ItemStack itemstack = player.getStackInHand(hand); + final NbtCompound tag = itemstack.get(TCRedstoneMain.COMPOUND_DATA); + if (tag != null) { + if (!hand.equals(Hand.MAIN_HAND) || level.isClient()) + return ActionResult.PASS; + final NbtCompound comp = getOrCreateNbt(itemstack); + if (comp.contains(LINKINGTOOL_TAG)) { + final Optional linkpos = NbtHelper.toBlockPos(comp, LINKINGTOOL_TAG); + final boolean state = TileRedstoneEmitter.redstoneUpdate(linkpos.get(), level); + message(player, "ra.state", String.valueOf(state)); + return ActionResult.SUCCESS; + } + } + return ActionResult.SUCCESS; } - } diff --git a/src/main/java/com/troblecodings/tcredstone/tile/TileRedstoneEmitter.java b/src/main/java/com/troblecodings/tcredstone/tile/TileRedstoneEmitter.java index 1748716..ad4dfb3 100644 --- a/src/main/java/com/troblecodings/tcredstone/tile/TileRedstoneEmitter.java +++ b/src/main/java/com/troblecodings/tcredstone/tile/TileRedstoneEmitter.java @@ -1,19 +1,22 @@ package com.troblecodings.tcredstone.tile; +import java.util.Optional; + import com.troblecodings.linkableapi.ILinkableTile; import com.troblecodings.tcredstone.block.BlockRedstoneAcceptor; -import com.troblecodings.tcredstone.init.GIRCInit; +import com.troblecodings.tcredstone.init.TCInit; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.RegistryWrapper.WrapperLookup; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; public class TileRedstoneEmitter extends BlockEntity implements ILinkableTile { public TileRedstoneEmitter(final BlockPos pos, final BlockState state) { - super(GIRCInit.EMITER_TILE.get(), pos, state); + super(TCInit.EMITER_TILE, pos, state); } private BlockPos linkedpos = null; @@ -22,7 +25,7 @@ public TileRedstoneEmitter(final BlockPos pos, final BlockState state) { private static final String ID_Y = "yLinkedPos"; private static final String ID_Z = "zLinkedPos"; - public static CompoundTag writeBlockPosToNBT(final BlockPos pos, final CompoundTag compound) { + public static NbtCompound writeBlockPosToNBT(final BlockPos pos, final NbtCompound compound) { if (pos != null && compound != null) { compound.putInt(ID_X, pos.getX()); compound.putInt(ID_Y, pos.getY()); @@ -31,32 +34,31 @@ public static CompoundTag writeBlockPosToNBT(final BlockPos pos, final CompoundT return compound; } - public static BlockPos readBlockPosFromNBT(final CompoundTag compound) { + public static BlockPos readBlockPosFromNBT(final NbtCompound compound) { if (compound != null && compound.contains(ID_X) && compound.contains(ID_Y) - && compound.contains(ID_Z)) { + && compound.contains(ID_Z)) return new BlockPos(compound.getInt(ID_X), compound.getInt(ID_Y), compound.getInt(ID_Z)); - } return null; } @Override - public void load(final CompoundTag compound) { - super.load(compound); + protected void readNbt(final NbtCompound compound, final WrapperLookup wrapperLookup) { + super.readNbt(compound, wrapperLookup); this.linkedpos = readBlockPosFromNBT(compound); } @Override - protected void saveAdditional(final CompoundTag compound) { - super.saveAdditional(compound); + protected void writeNbt(final NbtCompound compound, final WrapperLookup wrapperLookup) { + super.writeNbt(compound, wrapperLookup); writeBlockPosToNBT(linkedpos, compound); } @Override - public boolean link(final BlockPos pos) { + public boolean link(final Optional pos) { if (pos == null) return false; - this.linkedpos = pos; + this.linkedpos = pos.get(); return true; } @@ -73,26 +75,27 @@ public BlockPos getLinkedPos() { } public void redstoneUpdate(final boolean enabled) { - redstoneUpdate(enabled, linkedpos, level); + redstoneUpdate(enabled, linkedpos, world); } public static boolean redstoneUpdate(final boolean enabled, final BlockPos linkedpos, - final Level level) { + final World level) { if (linkedpos != null) { final BlockState state = level.getBlockState(linkedpos); if (state.getBlock() instanceof BlockRedstoneAcceptor) { - level.setBlock(linkedpos, state.setValue(BlockRedstoneAcceptor.POWER, enabled), 3); + level.setBlockState(linkedpos, state.with(BlockRedstoneAcceptor.POWER, enabled), 3); } } return enabled; } - public static boolean redstoneUpdate(final BlockPos linkedpos, final Level level) { + public static boolean redstoneUpdate(final BlockPos linkedpos, final World level) { if (linkedpos != null) { final BlockState state = level.getBlockState(linkedpos); if (state.getBlock() instanceof BlockRedstoneAcceptor) { - final boolean newState = !state.getValue(BlockRedstoneAcceptor.POWER); - level.setBlock(linkedpos, state.setValue(BlockRedstoneAcceptor.POWER, newState), 3); + final boolean newState = !state.get(BlockRedstoneAcceptor.POWER); + level.setBlockState(linkedpos, state.with(BlockRedstoneAcceptor.POWER, newState), + 3); return newState; } } diff --git a/src/main/java/com/troblecodings/tcredstone/tile/TileRedstoneMultiEmitter.java b/src/main/java/com/troblecodings/tcredstone/tile/TileRedstoneMultiEmitter.java index 0058fc4..9a0ff89 100644 --- a/src/main/java/com/troblecodings/tcredstone/tile/TileRedstoneMultiEmitter.java +++ b/src/main/java/com/troblecodings/tcredstone/tile/TileRedstoneMultiEmitter.java @@ -2,18 +2,23 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; import com.troblecodings.linkableapi.ILinkableTile; +import com.troblecodings.linkableapi.MultiLinkingTool; import com.troblecodings.tcredstone.block.BlockRedstoneAcceptor; -import com.troblecodings.tcredstone.init.GIRCInit; - -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.NbtUtils; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; +import com.troblecodings.tcredstone.init.TCInit; + +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; +import net.minecraft.nbt.NbtHelper; +import net.minecraft.nbt.NbtIntArray; +import net.minecraft.nbt.NbtList; +import net.minecraft.registry.RegistryWrapper.WrapperLookup; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; public class TileRedstoneMultiEmitter extends BlockEntity implements ILinkableTile { @@ -22,15 +27,15 @@ public class TileRedstoneMultiEmitter extends BlockEntity implements ILinkableTi private static final String LINKED_POS_LIST = "linkedPos"; public TileRedstoneMultiEmitter(final BlockPos pos, final BlockState state) { - super(GIRCInit.MULTI_EMITER_TILE.get(), pos, state); + super(TCInit.MULTI_EMITER_TILE, pos, state); } - public CompoundTag writeBlockPosToNBT(final List pos, final CompoundTag compound) { + public NbtCompound writeBlockPosToNBT(final List pos, final NbtCompound compound) { if (pos != null && compound != null) { - final ListTag list = new ListTag(); + final NbtList list = new NbtList(); listOfPositions.forEach(blockpos -> { - final CompoundTag item = NbtUtils.writeBlockPos(blockpos); + final NbtElement item = NbtHelper.fromBlockPos(blockpos); list.add(item); }); compound.put(LINKED_POS_LIST, list); @@ -38,13 +43,13 @@ public CompoundTag writeBlockPosToNBT(final List pos, final CompoundTa return compound; } - public List readBlockPosFromNBT(final CompoundTag compound) { - final ListTag list = (ListTag) compound.get(LINKED_POS_LIST); + public List readBlockPosFromNBT(final NbtCompound compound) { + final NbtList list = (NbtList) compound.get(LINKED_POS_LIST); if (list != null) { listOfPositions.clear(); list.forEach(pos -> { - final CompoundTag item = (CompoundTag) pos; - listOfPositions.add(NbtUtils.readBlockPos(item)); + listOfPositions + .add(MultiLinkingTool.toBlockPos((NbtIntArray) pos, LINKED_POS_LIST).get()); }); return listOfPositions; } @@ -57,9 +62,9 @@ public boolean hasLink() { } @Override - public boolean link(final BlockPos pos) { - if (pos != null && !listOfPositions.contains(pos)) { - listOfPositions.add(pos); + public boolean link(final Optional pos) { + if (pos != null && !listOfPositions.contains(pos.get())) { + listOfPositions.add(pos.get()); return true; } return false; @@ -78,38 +83,39 @@ public List getLinkedPos() { } @Override - public void load(final CompoundTag compound) { - super.load(compound); + protected void readNbt(final NbtCompound compound, final WrapperLookup wrapperLookup) { + super.readNbt(compound, wrapperLookup); this.listOfPositions = readBlockPosFromNBT(compound); } @Override - protected void saveAdditional(final CompoundTag compound) { - super.saveAdditional(compound); + protected void writeNbt(final NbtCompound compound, final WrapperLookup wrapperLookup) { + super.writeNbt(compound, wrapperLookup); writeBlockPosToNBT(listOfPositions, compound); } public void redstoneUpdate(final boolean enabled) { - listOfPositions.forEach(blockpos -> redstoneUpdate(enabled, blockpos, level)); + listOfPositions.forEach(blockpos -> redstoneUpdate(enabled, blockpos, world)); } public static boolean redstoneUpdate(final boolean enabled, final BlockPos linkedpos, - final Level level) { + final World level) { if (linkedpos != null) { final BlockState state = level.getBlockState(linkedpos); if (state.getBlock() instanceof BlockRedstoneAcceptor) { - level.setBlock(linkedpos, state.setValue(BlockRedstoneAcceptor.POWER, enabled), 3); + level.setBlockState(linkedpos, state.with(BlockRedstoneAcceptor.POWER, enabled), 3); } } return enabled; } - public static boolean redstoneUpdate(final BlockPos linkedpos, final Level level) { + public static boolean redstoneUpdate(final BlockPos linkedpos, final World level) { if (linkedpos != null) { final BlockState state = level.getBlockState(linkedpos); if (state.getBlock() instanceof BlockRedstoneAcceptor) { - final boolean newState = !state.getValue(BlockRedstoneAcceptor.POWER); - level.setBlock(linkedpos, state.setValue(BlockRedstoneAcceptor.POWER, newState), 3); + final boolean newState = !state.get(BlockRedstoneAcceptor.POWER); + level.setBlockState(linkedpos, state.with(BlockRedstoneAcceptor.POWER, newState), + 3); return newState; } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 51b01c9..0000000 --- a/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,26 +0,0 @@ -modLoader="javafml" -loaderVersion="[46,)" -issueTrackerURL="https://github.com/German-Immersive-Railroading-Community/GIRC-Redstone/issues" -license="Apache License Version 2.0" - -[[mods]] -modId="gircredstone" -version="${file.jarVersion}" -displayName="TC Redstone" -displayURL="https://troblecodings.com/" -authors="MrTroble, Jeronimo" -description="Works in unloaded Chunks TM." - -[[dependencies.gircredstone]] - modId="forge" - mandatory=true - versionRange="[46,)" - ordering="NONE" - side="BOTH" - -[[dependencies.gircredstone]] - modId="minecraft" - mandatory=true - versionRange="[1.20,)" - ordering="NONE" - side="BOTH" diff --git a/src/main/resources/assets/gircredstone/blockstates/acceptor.json b/src/main/resources/assets/gircredstone/blockstates/acceptor.json deleted file mode 100644 index 1800e68..0000000 --- a/src/main/resources/assets/gircredstone/blockstates/acceptor.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "variants": { - "power=false": { - "model": "gircredstone:block/acceptor_off" - }, - "power=true": { - "model": "gircredstone:block/acceptor_on" - } - } -} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/blockstates/multiemitter.json b/src/main/resources/assets/gircredstone/blockstates/multiemitter.json deleted file mode 100644 index d5ecfa8..0000000 --- a/src/main/resources/assets/gircredstone/blockstates/multiemitter.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "variants": { - "": { - "model": "gircredstone:block/multiemitter" - } - } -} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/block/acceptor_off.json b/src/main/resources/assets/gircredstone/models/block/acceptor_off.json deleted file mode 100644 index 918c27e..0000000 --- a/src/main/resources/assets/gircredstone/models/block/acceptor_off.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "minecraft:block/cube_all", "textures": {"all": "gircredstone:block/acceptor_off"}} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/block/acceptor_on.json b/src/main/resources/assets/gircredstone/models/block/acceptor_on.json deleted file mode 100644 index c2071eb..0000000 --- a/src/main/resources/assets/gircredstone/models/block/acceptor_on.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "minecraft:block/cube_all", "textures": {"all": "gircredstone:block/acceptor_on"}} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/block/emitter.json b/src/main/resources/assets/gircredstone/models/block/emitter.json deleted file mode 100644 index 49a701a..0000000 --- a/src/main/resources/assets/gircredstone/models/block/emitter.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "minecraft:block/cube_all", "textures": {"all": "gircredstone:block/emitter"}} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/block/multiemitter.json b/src/main/resources/assets/gircredstone/models/block/multiemitter.json deleted file mode 100644 index 4b50b58..0000000 --- a/src/main/resources/assets/gircredstone/models/block/multiemitter.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "block/cube_all", "textures": {"all": "gircredstone:block/multiemitter"}} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/item/acceptor.json b/src/main/resources/assets/gircredstone/models/item/acceptor.json deleted file mode 100644 index 7f25cfe..0000000 --- a/src/main/resources/assets/gircredstone/models/item/acceptor.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "gircredstone:block/acceptor_off", "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/item/activator.json b/src/main/resources/assets/gircredstone/models/item/activator.json deleted file mode 100644 index 09a1059..0000000 --- a/src/main/resources/assets/gircredstone/models/item/activator.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "minecraft:item/generated", "textures": {"layer0": "gircredstone:item/activator"}, "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/item/emitter.json b/src/main/resources/assets/gircredstone/models/item/emitter.json deleted file mode 100644 index 17e3251..0000000 --- a/src/main/resources/assets/gircredstone/models/item/emitter.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "gircredstone:block/emitter", "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/item/linker.json b/src/main/resources/assets/gircredstone/models/item/linker.json deleted file mode 100644 index 03dd37c..0000000 --- a/src/main/resources/assets/gircredstone/models/item/linker.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "minecraft:item/generated", "textures": {"layer0": "gircredstone:item/linker"}, "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/item/multiemitter.json b/src/main/resources/assets/gircredstone/models/item/multiemitter.json deleted file mode 100644 index 70eda32..0000000 --- a/src/main/resources/assets/gircredstone/models/item/multiemitter.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "gircredstone:block/multiemitter", "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/models/item/multilinker.json b/src/main/resources/assets/gircredstone/models/item/multilinker.json deleted file mode 100644 index 6685795..0000000 --- a/src/main/resources/assets/gircredstone/models/item/multilinker.json +++ /dev/null @@ -1 +0,0 @@ -{"parent": "minecraft:item/generated", "textures": {"layer0": "gircredstone:item/multilinker"}, "credit": "Made with Blockbench by Mc_Jeronimo"} diff --git a/src/main/resources/assets/tcredstone/blockstates/acceptor.json b/src/main/resources/assets/tcredstone/blockstates/acceptor.json new file mode 100644 index 0000000..9d89d56 --- /dev/null +++ b/src/main/resources/assets/tcredstone/blockstates/acceptor.json @@ -0,0 +1,10 @@ +{ + "variants": { + "power=false": { + "model": "tcredstone:block/acceptor_off" + }, + "power=true": { + "model": "tcredstone:block/acceptor_on" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/gircredstone/blockstates/emitter.json b/src/main/resources/assets/tcredstone/blockstates/emitter.json similarity index 50% rename from src/main/resources/assets/gircredstone/blockstates/emitter.json rename to src/main/resources/assets/tcredstone/blockstates/emitter.json index 5e82308..d8adc59 100644 --- a/src/main/resources/assets/gircredstone/blockstates/emitter.json +++ b/src/main/resources/assets/tcredstone/blockstates/emitter.json @@ -1,7 +1,7 @@ { "variants": { "": { - "model": "gircredstone:block/emitter" + "model": "tcredstone:block/emitter" } } } \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/blockstates/multiemitter.json b/src/main/resources/assets/tcredstone/blockstates/multiemitter.json new file mode 100644 index 0000000..f042e8a --- /dev/null +++ b/src/main/resources/assets/tcredstone/blockstates/multiemitter.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "tcredstone:block/multiemitter" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/icon.png b/src/main/resources/assets/tcredstone/icon.png new file mode 100644 index 0000000..047b91f Binary files /dev/null and b/src/main/resources/assets/tcredstone/icon.png differ diff --git a/src/main/resources/assets/tcredstone/items/acceptor.json b/src/main/resources/assets/tcredstone/items/acceptor.json new file mode 100644 index 0000000..4084db9 --- /dev/null +++ b/src/main/resources/assets/tcredstone/items/acceptor.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "tcredstone:item/acceptor" + } +} diff --git a/src/main/resources/assets/tcredstone/items/activator.json b/src/main/resources/assets/tcredstone/items/activator.json new file mode 100644 index 0000000..4ceac5a --- /dev/null +++ b/src/main/resources/assets/tcredstone/items/activator.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "tcredstone:item/activator" + } +} diff --git a/src/main/resources/assets/tcredstone/items/emitter.json b/src/main/resources/assets/tcredstone/items/emitter.json new file mode 100644 index 0000000..3881e91 --- /dev/null +++ b/src/main/resources/assets/tcredstone/items/emitter.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "tcredstone:item/emitter" + } +} diff --git a/src/main/resources/assets/tcredstone/items/linker.json b/src/main/resources/assets/tcredstone/items/linker.json new file mode 100644 index 0000000..4798e7b --- /dev/null +++ b/src/main/resources/assets/tcredstone/items/linker.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "tcredstone:item/linker" + } +} diff --git a/src/main/resources/assets/tcredstone/items/multiemitter.json b/src/main/resources/assets/tcredstone/items/multiemitter.json new file mode 100644 index 0000000..a5869a3 --- /dev/null +++ b/src/main/resources/assets/tcredstone/items/multiemitter.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "tcredstone:item/multiemitter" + } +} diff --git a/src/main/resources/assets/tcredstone/items/multilinker.json b/src/main/resources/assets/tcredstone/items/multilinker.json new file mode 100644 index 0000000..fe4d1e5 --- /dev/null +++ b/src/main/resources/assets/tcredstone/items/multilinker.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "tcredstone:item/multilinker" + } +} diff --git a/src/main/resources/assets/gircredstone/lang/de_de.json b/src/main/resources/assets/tcredstone/lang/de_de.json similarity index 66% rename from src/main/resources/assets/gircredstone/lang/de_de.json rename to src/main/resources/assets/tcredstone/lang/de_de.json index 71146e8..4e0b4c0 100644 --- a/src/main/resources/assets/gircredstone/lang/de_de.json +++ b/src/main/resources/assets/tcredstone/lang/de_de.json @@ -1,10 +1,10 @@ { - "item.gircredstone.linker": "WLR Verlinker", - "item.gircredstone.multilinker": "WLR Multi Verlinker", - "item.gircredstone.activator": "WLR Fernaktivator", - "block.gircredstone.emitter": "WLR Signal-Sender", - "block.gircredstone.multiemitter": "WLR Multi-Signal-Sender", - "block.gircredstone.acceptor": "WLR Signal-Akzeptor", + "item.tcredstone.linker": "WLR Verlinker", + "item.tcredstone.multilinker": "WLR Multi Verlinker", + "item.tcredstone.activator": "WLR Fernaktivator", + "block.tcredstone.emitter": "WLR Signal-Sender", + "block.tcredstone.multiemitter": "WLR Multi-Signal-Sender", + "block.tcredstone.acceptor": "WLR Signal-Akzeptor", "lt.linkedpos": "§2Verlinkt mit: {%d, %d, %d§2}§r", "lt.setpos": "§2Gesetzt auf: {%d, %d, %d§2}§r", "lt.setpos.msg": "§l§9Bitte klicke auf einen Signal-Sender um die Verknüpfung herzustellen.§r", diff --git a/src/main/resources/assets/gircredstone/lang/en_us.json b/src/main/resources/assets/tcredstone/lang/en_us.json similarity index 64% rename from src/main/resources/assets/gircredstone/lang/en_us.json rename to src/main/resources/assets/tcredstone/lang/en_us.json index c701ff6..1d31fd4 100644 --- a/src/main/resources/assets/gircredstone/lang/en_us.json +++ b/src/main/resources/assets/tcredstone/lang/en_us.json @@ -1,10 +1,10 @@ { - "item.gircredstone.linker": "WLR Linker", - "item.gircredstone.multilinker": "WLR Multi Linker", - "item.gircredstone.activator": "WLR Remote Activator", - "block.gircredstone.emitter": "WLR Emitter", - "block.gircredstone.multiemitter": "WLR Multi-Emitter", - "block.gircredstone.acceptor": "WLR Acceptor", + "item.tcredstone.linker": "WLR Linker", + "item.tcredstone.multilinker": "WLR Multi Linker", + "item.tcredstone.activator": "WLR Remote Activator", + "block.tcredstone.emitter": "WLR Emitter", + "block.tcredstone.multiemitter": "WLR Multi-Emitter", + "block.tcredstone.acceptor": "WLR Acceptor", "lt.linkedpos": "§2Linked to: {%d, %d, %d§2}§r", "lt.setpos": "§2Set to: {%d, %d, %d§2}§r", "lt.setpos.msg": "§l§9Please click on an Emitter to set the link.§r", diff --git a/src/main/resources/assets/gircredstone/lang/pt_br.json b/src/main/resources/assets/tcredstone/lang/pt_br.json similarity index 64% rename from src/main/resources/assets/gircredstone/lang/pt_br.json rename to src/main/resources/assets/tcredstone/lang/pt_br.json index 0ac7f7d..3b79e0d 100644 --- a/src/main/resources/assets/gircredstone/lang/pt_br.json +++ b/src/main/resources/assets/tcredstone/lang/pt_br.json @@ -1,19 +1,19 @@ -{ - "item.gircredstone.linker": "WLR Vinculador", - "item.gircredstone.multilinker": "WLR Múltiplo Vinculador", - "item.gircredstone.activator": "WLR Ativador Remoto", - "block.gircredstone.emitter": "WLR Emissor", - "block.gircredstone.multiemitter": "WLR Multi-Emissor", - "block.gircredstone.acceptor": "WLR Receptor", - "lt.linkedpos": "§2Ligado a: {%d, %d, %d§2}§r", - "lt.setpos": "§2Definido como: {%d, %d, %d§2}§r", - "lt.setpos.msg": "§l§9Por favor, clique em um emissor para definir o link.§r", - "lt.notlinked": "§cNão ligado!§r", - "lt.notlinked.msg": "§l§9Por favor, clique em um aceitador para vincular.§r", - "lt.reset": "§cA ferramenta foi redefinida.§r", - "lt.notset": "§cA ferramenta não está vinculado.§r", - "lt.unlink": "§cEmissor não está mais vinculado!§r", - "em.notlinked": "§cEmissor não está vinculado!§r", - "em.unlink": "§cDesvinculado.§r", - "ra.state": "Ativado: %s" +{ + "item.tcredstone.linker": "WLR Vinculador", + "item.tcredstone.multilinker": "WLR Múltiplo Vinculador", + "item.tcredstone.activator": "WLR Ativador Remoto", + "block.tcredstone.emitter": "WLR Emissor", + "block.tcredstone.multiemitter": "WLR Multi-Emissor", + "block.tcredstone.acceptor": "WLR Receptor", + "lt.linkedpos": "§2Ligado a: {%d, %d, %d§2}§r", + "lt.setpos": "§2Definido como: {%d, %d, %d§2}§r", + "lt.setpos.msg": "§l§9Por favor, clique em um emissor para definir o link.§r", + "lt.notlinked": "§cNão ligado!§r", + "lt.notlinked.msg": "§l§9Por favor, clique em um aceitador para vincular.§r", + "lt.reset": "§cA ferramenta foi redefinida.§r", + "lt.notset": "§cA ferramenta não está vinculado.§r", + "lt.unlink": "§cEmissor não está mais vinculado!§r", + "em.notlinked": "§cEmissor não está vinculado!§r", + "em.unlink": "§cDesvinculado.§r", + "ra.state": "Ativado: %s" } \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/block/acceptor_off.json b/src/main/resources/assets/tcredstone/models/block/acceptor_off.json new file mode 100644 index 0000000..7067346 --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/block/acceptor_off.json @@ -0,0 +1 @@ +{"parent": "minecraft:block/cube_all", "textures": {"all": "tcredstone:block/acceptor_off"}} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/block/acceptor_on.json b/src/main/resources/assets/tcredstone/models/block/acceptor_on.json new file mode 100644 index 0000000..ab73642 --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/block/acceptor_on.json @@ -0,0 +1 @@ +{"parent": "minecraft:block/cube_all", "textures": {"all": "tcredstone:block/acceptor_on"}} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/block/emitter.json b/src/main/resources/assets/tcredstone/models/block/emitter.json new file mode 100644 index 0000000..e3d4513 --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/block/emitter.json @@ -0,0 +1 @@ +{"parent": "minecraft:block/cube_all", "textures": {"all": "tcredstone:block/emitter"}} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/block/multiemitter.json b/src/main/resources/assets/tcredstone/models/block/multiemitter.json new file mode 100644 index 0000000..bed828c --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/block/multiemitter.json @@ -0,0 +1 @@ +{"parent": "block/cube_all", "textures": {"all": "tcredstone:block/multiemitter"}} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/item/acceptor.json b/src/main/resources/assets/tcredstone/models/item/acceptor.json new file mode 100644 index 0000000..d11c23d --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/item/acceptor.json @@ -0,0 +1 @@ +{"parent": "tcredstone:block/acceptor_off", "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/item/activator.json b/src/main/resources/assets/tcredstone/models/item/activator.json new file mode 100644 index 0000000..e709f7c --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/item/activator.json @@ -0,0 +1 @@ +{"parent": "minecraft:item/generated", "textures": {"layer0": "tcredstone:item/activator"}, "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/item/emitter.json b/src/main/resources/assets/tcredstone/models/item/emitter.json new file mode 100644 index 0000000..f96f23f --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/item/emitter.json @@ -0,0 +1 @@ +{"parent": "tcredstone:block/emitter", "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/item/linker.json b/src/main/resources/assets/tcredstone/models/item/linker.json new file mode 100644 index 0000000..ceedcff --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/item/linker.json @@ -0,0 +1 @@ +{"parent": "minecraft:item/generated", "textures": {"layer0": "tcredstone:item/linker"}, "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/item/multiemitter.json b/src/main/resources/assets/tcredstone/models/item/multiemitter.json new file mode 100644 index 0000000..298a30b --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/item/multiemitter.json @@ -0,0 +1 @@ +{"parent": "tcredstone:block/multiemitter", "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/tcredstone/models/item/multilinker.json b/src/main/resources/assets/tcredstone/models/item/multilinker.json new file mode 100644 index 0000000..d1b5937 --- /dev/null +++ b/src/main/resources/assets/tcredstone/models/item/multilinker.json @@ -0,0 +1 @@ +{"parent": "minecraft:item/generated", "textures": {"layer0": "tcredstone:item/multilinker"}, "credit": "Made with Blockbench by Mc_Jeronimo"} diff --git a/src/main/resources/assets/gircredstone/textures/block/acceptor_off.png b/src/main/resources/assets/tcredstone/textures/block/acceptor_off.png similarity index 100% rename from src/main/resources/assets/gircredstone/textures/block/acceptor_off.png rename to src/main/resources/assets/tcredstone/textures/block/acceptor_off.png diff --git a/src/main/resources/assets/gircredstone/textures/block/acceptor_on.png b/src/main/resources/assets/tcredstone/textures/block/acceptor_on.png similarity index 100% rename from src/main/resources/assets/gircredstone/textures/block/acceptor_on.png rename to src/main/resources/assets/tcredstone/textures/block/acceptor_on.png diff --git a/src/main/resources/assets/gircredstone/textures/block/emitter.png b/src/main/resources/assets/tcredstone/textures/block/emitter.png similarity index 100% rename from src/main/resources/assets/gircredstone/textures/block/emitter.png rename to src/main/resources/assets/tcredstone/textures/block/emitter.png diff --git a/src/main/resources/assets/gircredstone/textures/block/multiemitter.png b/src/main/resources/assets/tcredstone/textures/block/multiemitter.png similarity index 100% rename from src/main/resources/assets/gircredstone/textures/block/multiemitter.png rename to src/main/resources/assets/tcredstone/textures/block/multiemitter.png diff --git a/src/main/resources/assets/gircredstone/textures/item/activator.png b/src/main/resources/assets/tcredstone/textures/item/activator.png similarity index 100% rename from src/main/resources/assets/gircredstone/textures/item/activator.png rename to src/main/resources/assets/tcredstone/textures/item/activator.png diff --git a/src/main/resources/assets/gircredstone/textures/item/linker.png b/src/main/resources/assets/tcredstone/textures/item/linker.png similarity index 100% rename from src/main/resources/assets/gircredstone/textures/item/linker.png rename to src/main/resources/assets/tcredstone/textures/item/linker.png diff --git a/src/main/resources/assets/gircredstone/textures/item/multilinker.png b/src/main/resources/assets/tcredstone/textures/item/multilinker.png similarity index 100% rename from src/main/resources/assets/gircredstone/textures/item/multilinker.png rename to src/main/resources/assets/tcredstone/textures/item/multilinker.png diff --git a/src/main/resources/data/gircredstone/loot_tables/blocks/acceptor.json b/src/main/resources/data/gircredstone/loot_tables/blocks/acceptor.json deleted file mode 100644 index e5b9d5d..0000000 --- a/src/main/resources/data/gircredstone/loot_tables/blocks/acceptor.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1.0, - "bonus_rolls": 0.0, - "entries": [ - { - "type": "minecraft:item", - "name": "gircredstone:acceptor" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/gircredstone/loot_tables/blocks/emitter.json b/src/main/resources/data/gircredstone/loot_tables/blocks/emitter.json deleted file mode 100644 index b92d5e4..0000000 --- a/src/main/resources/data/gircredstone/loot_tables/blocks/emitter.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1.0, - "bonus_rolls": 0.0, - "entries": [ - { - "type": "minecraft:item", - "name": "gircredstone:emitter" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/gircredstone/loot_tables/blocks/multiemitter.json b/src/main/resources/data/gircredstone/loot_tables/blocks/multiemitter.json deleted file mode 100644 index 8c8051f..0000000 --- a/src/main/resources/data/gircredstone/loot_tables/blocks/multiemitter.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1.0, - "bonus_rolls": 0.0, - "entries": [ - { - "type": "minecraft:item", - "name": "gircredstone:multiemitter" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/gircredstone/recipes/acceptor.json b/src/main/resources/data/gircredstone/recipes/acceptor.json deleted file mode 100644 index 199ab25..0000000 --- a/src/main/resources/data/gircredstone/recipes/acceptor.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "type": "crafting_shaped", - "pattern": [ - "IiI", - "XYX", - "IZI" - ], - "key": { - "I": { - "item": "minecraft:redstone_block" - }, - "i": { - "item": "minecraft:redstone_torch" - }, - "X": { - "item": "minecraft:white_concrete" - }, - "Y": { - "item": "minecraft:obsidian" - }, - "Z": { - "item": "minecraft:diamond" - } - }, - "result": { - "item": "gircredstone:acceptor" - } -} \ No newline at end of file diff --git a/src/main/resources/data/gircredstone/recipes/activator.json b/src/main/resources/data/gircredstone/recipes/activator.json deleted file mode 100644 index 955c695..0000000 --- a/src/main/resources/data/gircredstone/recipes/activator.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - " ", - " I ", - " i " - ], - "key": { - "I": { - "item": "minecraft:redstone" - }, - "i": { - "item": "minecraft:lever" - } - }, - "result": { - "item": "gircredstone:activator" - } -} \ No newline at end of file diff --git a/src/main/resources/data/gircredstone/recipes/emitter.json b/src/main/resources/data/gircredstone/recipes/emitter.json deleted file mode 100644 index ce7f2dc..0000000 --- a/src/main/resources/data/gircredstone/recipes/emitter.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "type": "crafting_shaped", - "pattern": [ - "IiI", - "XYX", - "IZI" - ], - "key": { - "I": { - "item": "minecraft:redstone_block" - }, - "i": { - "item": "minecraft:redstone" - }, - "X": { - "item": "minecraft:white_concrete" - }, - "Y": { - "item": "minecraft:obsidian" - }, - "Z": { - "item": "minecraft:diamond" - } - }, - "result": { - "item": "gircredstone:emitter" - } -} \ No newline at end of file diff --git a/src/main/resources/data/gircredstone/recipes/linker.json b/src/main/resources/data/gircredstone/recipes/linker.json deleted file mode 100644 index 3307d4f..0000000 --- a/src/main/resources/data/gircredstone/recipes/linker.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - " ", - " I ", - " i " - ], - "key": { - "I": { - "item": "minecraft:quartz" - }, - "i": { - "item": "minecraft:redstone_torch" - } - }, - "result": { - "item": "gircredstone:linker" - } -} \ No newline at end of file diff --git a/src/main/resources/data/gircredstone/recipes/multiemitter.json b/src/main/resources/data/gircredstone/recipes/multiemitter.json deleted file mode 100644 index 703ffd4..0000000 --- a/src/main/resources/data/gircredstone/recipes/multiemitter.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "type": "crafting_shaped", - "pattern": [ - "IZI", - "XYX", - "IiI" - ], - "key": { - "I": { - "item": "minecraft:redstone_block" - }, - "i": { - "item": "minecraft:redstone" - }, - "X": { - "item": "minecraft:white_concrete" - }, - "Y": { - "item": "minecraft:obsidian" - }, - "Z": { - "item": "minecraft:diamond" - } - }, - "result": { - "item": "gircredstone:multiemitter" - } -} \ No newline at end of file diff --git a/src/main/resources/data/gircredstone/recipes/multilinker.json b/src/main/resources/data/gircredstone/recipes/multilinker.json deleted file mode 100644 index 359c559..0000000 --- a/src/main/resources/data/gircredstone/recipes/multilinker.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - " I ", - " i ", - " x " - ], - "key": { - "I": { - "item": "minecraft:quartz" - }, - "i": { - "item": "minecraft:redstone_torch" - }, - "x": { - "item": "minecraft:diamond" - } - }, - "result": { - "item": "gircredstone:multilinker" - } -} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json deleted file mode 100644 index 857c38b..0000000 --- a/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "replace": false, - "values": [ - "gircredstone:acceptor", - "gircredstone:emitter", - "gircredstone:multiemitter" - ] -} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json b/src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json deleted file mode 100644 index 857c38b..0000000 --- a/src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "replace": false, - "values": [ - "gircredstone:acceptor", - "gircredstone:emitter", - "gircredstone:multiemitter" - ] -} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..5416fa0 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,32 @@ +{ + "schemaVersion": 1, + "id": "tcredstone", + "version": "${version}", + "name": "TC Redstone", + "description": "Best Wireless Redstone Mod. :tm:", + "authors": [ + "MrTroble", + "Jeronimo" + ], + "contact": { + "homepage": "https://fabricmc.net/", + "sources": "https://github.com/FabricMC/fabric-example-mod" + }, + "license": "Apache License Version 2.0", + "icon": "assets/tcredstone/icon.png", + "environment": "*", + "entrypoints": { + "main": [ + "com.troblecodings.tcredstone.TCRedstoneMain" + ] + }, + "depends": { + "fabricloader": ">=0.16.14", + "minecraft": "~1.21.4", + "java": ">=21", + "fabric-api": "*" + }, + "suggests": { + "another-mod": "*" + } +} \ No newline at end of file diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta deleted file mode 100644 index d81f1da..0000000 --- a/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,8 +0,0 @@ -{ - "pack": { - "description": "TC Wireless-Redstone", - "pack_format": 15, - "forge:resource_pack_format": 15, - "forge:data_pack_format": 15 - } -}