diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b5421bd..6f06526 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -12,14 +12,14 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 1.17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: 'adopt' java-version: 17 - name: Cache Gradle packages - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -30,7 +30,7 @@ jobs: - name: Build with Gradle run: ./gradlew build - name: Upload Artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: jars path: build/libs diff --git a/.github/workflows/minepkg-publish.yml b/.github/workflows/minepkg-publish.yml index 9be6102..8b122e7 100644 --- a/.github/workflows/minepkg-publish.yml +++ b/.github/workflows/minepkg-publish.yml @@ -8,9 +8,9 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 1.17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: 'adopt' java-version: 17 diff --git a/.minepkg-lock.toml b/.minepkg-lock.toml index 8be0384..b106a03 100644 --- a/.minepkg-lock.toml +++ b/.minepkg-lock.toml @@ -4,30 +4,30 @@ lockfileVersion = 1 [fabric] - minecraft = "1.19.4" - fabricLoader = "0.14.18" - mapping = "1.19.4+build.1" + minecraft = "1.20" + fabricLoader = "0.16.10" + mapping = "1.20+build.1" [dependencies] [dependencies.fabric] name = "fabric" - version = "0.76.0+1.19.4.mpkg.1" + version = "0.92.3+1.20.1.mpkg.1" versionName = "" type = "mod" - ipfsHash = "QmPkXR4psTFUZXWTKFhcZsZtjE1BGpB99uS3yad1zHkLMq" - Sha256 = "63f4afaebc91dfaa40102294b24309397c18c4c2f824920613f435d23b3b04c0" - url = "https://api.preview.minepkg.io/v1/releases/fabric/fabric@0.76.0+1.19.4.mpkg.1/download" + ipfsHash = "" + Sha256 = "57e606b4afd5f8d6faefc78432fa0e813d3d2e59365cdb0e832ee2bbb6eef59a" + url = "https://api.preview.minepkg.io/v1/releases/fabric/fabric@0.92.3+1.20.1.mpkg.1/download" provider = "minepkg" dependent = "" [dependencies.minepkg-companion] name = "minepkg-companion" - version = "0.7.0" + version = "0.8.0" versionName = "" type = "mod" - ipfsHash = "QmeEMaQt17m6u1ynFMKqVxa6tBx7wyHtHPrQn3g8DQ2Yww" - Sha256 = "e81e923c709140cdfc6f4532c9574abfedc771ca8979e71f5fa90fafc0a4d1ee" - url = "https://api.preview.minepkg.io/v1/releases/fabric/minepkg-companion@0.7.0/download" + ipfsHash = "" + Sha256 = "f401f1c544db05482bfd9dcb87454cb9e815c9e819aa60391af8c9c355ac2d44" + url = "https://api.preview.minepkg.io/v1/releases/fabric/minepkg-companion@0.8.0/download" provider = "minepkg" dependent = "" diff --git a/build.gradle b/build.gradle index 672356d..985143a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,15 @@ plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' + id 'fabric-loom' version '1.10-SNAPSHOT' id 'maven-publish' } -targetCompatibility = sourceCompatibility = JavaVersion.VERSION_17 - -archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group +base { + archivesName = project.archives_base_name +} + repositories { maven { name = "CottonMC" @@ -28,21 +29,25 @@ dependencies { } processResources { - inputs.property "version", project.version + def toExpand = [ + "version": project.version, + "java_version": project.java_version, + "minecraft_version_range": project.minecraft_version_range, + ] + + inputs.properties toExpand filesMatching("fabric.mod.json") { - expand "version": project.version + expand toExpand } } tasks.withType(JavaCompile) { - options.release = 17 + it.options.release = project.java_version as Integer } -// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task -// if it is present. -// If you remove this task, sources will not be generated. java { + targetCompatibility = sourceCompatibility = JavaVersion.toVersion(project.java_version as Integer) withSourcesJar() } diff --git a/gradle.properties b/gradle.properties index ad815ab..c0d92b5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/versions.html -minecraft_version=1.19.4 -yarn_mappings=1.19.4+build.1 -loader_version=0.14.14 +minecraft_version=1.20 +yarn_mappings=1.20+build.1 +loader_version=0.16.10 # Mod Properties mod_version=0.5.0 @@ -13,5 +13,8 @@ maven_group=io.minepkg archives_base_name=test-utils # Dependencies -fabric_version=0.73.2+1.19.3 -libgui_version=7.0.0-beta.2+1.19.4 +fabric_version=0.83.0+1.20 +libgui_version=8.0.1+1.20 + +minecraft_version_range=>=1.20.0 <=1.20.1 +java_version=17 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..9bbc975 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 00e33ed..37f853b 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-7.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..faf9300 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -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 @@ -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,11 +200,15 @@ 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" \ @@ -205,6 +216,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# 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 ac1b06f..9b42019 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,11 +59,11 @@ 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 @@ -75,13 +78,15 @@ set CLASSPATH=%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/minepkg.toml b/minepkg.toml index def11ff..58cfced 100755 --- a/minepkg.toml +++ b/minepkg.toml @@ -13,7 +13,7 @@ manifestVersion = 0 # These are global requirements [requirements] - minecraft = "~1.19.4" + minecraft = ">=1.20.0 <=1.20.1" fabricLoader = "*" [dependencies] diff --git a/src/main/java/io/minepkg/testutils/RuleBookGUI.java b/src/main/java/io/minepkg/testutils/RuleBookGUI.java index 944ef3f..359d6e1 100644 --- a/src/main/java/io/minepkg/testutils/RuleBookGUI.java +++ b/src/main/java/io/minepkg/testutils/RuleBookGUI.java @@ -224,7 +224,7 @@ private void setTime(long timeOfDay) { PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer()); passedData.writeLong(timeOfDay); // Send packet to server to change the time - ClientPlayNetworking.send(TestUtils.SET_TIME_PACKET_ID, passedData); + ClientPlayNetworking.send(TestUtils.SET_TIME_C2S, passedData); timeSlider.setValue((int)timeOfDay, false); envBox.setTimeOfDay(timeOfDay); // TODO: wait for response instead @@ -238,7 +238,7 @@ private void setRule(short id, boolean value) { passedData.writeShort(id); // enabling the button locks the weather passedData.writeBoolean(value); - ClientPlayNetworking.send(TestUtils.SET_RULE_PACKET_ID, passedData); + ClientPlayNetworking.send(TestUtils.SET_RULE_C2S, passedData); preventTickUpdates = 20; } @@ -246,7 +246,7 @@ private void setWeather(short weather) { preventTickUpdates += 1; PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer()); passedData.writeShort(weather); - ClientPlayNetworking.send(TestUtils.SET_WEATHER_PACKET_ID, passedData); + ClientPlayNetworking.send(TestUtils.SET_WEATHER_C2S, passedData); preventTickUpdates = 30; } } diff --git a/src/main/java/io/minepkg/testutils/RuleBookItem.java b/src/main/java/io/minepkg/testutils/RuleBookItem.java index 087adb2..657f417 100644 --- a/src/main/java/io/minepkg/testutils/RuleBookItem.java +++ b/src/main/java/io/minepkg/testutils/RuleBookItem.java @@ -1,11 +1,9 @@ package io.minepkg.testutils; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; @@ -17,13 +15,16 @@ public RuleBookItem(Settings settings) { super(settings); } - @Environment(EnvType.CLIENT) @Override public TypedActionResult use(World world, PlayerEntity playerEntity, Hand hand) { if (world.isClient) { playerEntity.playSound(SoundEvents.ITEM_BOOK_PAGE_TURN, 1.0F, 1.0F); - MinecraftClient.getInstance().setScreen(new RuleBookScreen(new RuleBookGUI(world, playerEntity))); + } else { + ServerPlayerEntity serverPlayer = (ServerPlayerEntity) playerEntity; + TestUtils.sendWeatherRule(serverPlayer); + TestUtils.sendOpenBookPacket(serverPlayer); } + return new TypedActionResult<>(ActionResult.SUCCESS, playerEntity.getStackInHand(hand)); } } diff --git a/src/main/java/io/minepkg/testutils/RuleBookScreen.java b/src/main/java/io/minepkg/testutils/RuleBookScreen.java index 701f8c5..2380376 100644 --- a/src/main/java/io/minepkg/testutils/RuleBookScreen.java +++ b/src/main/java/io/minepkg/testutils/RuleBookScreen.java @@ -2,23 +2,17 @@ import io.github.cottonmc.cotton.gui.GuiDescription; import io.github.cottonmc.cotton.gui.client.CottonClientScreen; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; public class RuleBookScreen extends CottonClientScreen { public RuleBookScreen(GuiDescription description) { super(description); - // Request the latest "doWeatherCycle" rule value - ClientPlayNetworking.send(TestUtils.WEATHER_GAMERULE_SYNC_REQUEST, PacketByteBufs.empty()); } - public boolean pausesGame() { + @Override + public boolean shouldPause() { return false; } - @Override - public boolean shouldPause() { return false; } - @Override public void tick() { ((RuleBookGUI)this.getDescription()).tick(); diff --git a/src/main/java/io/minepkg/testutils/TestUtils.java b/src/main/java/io/minepkg/testutils/TestUtils.java index 0da9c45..aa3d979 100644 --- a/src/main/java/io/minepkg/testutils/TestUtils.java +++ b/src/main/java/io/minepkg/testutils/TestUtils.java @@ -10,6 +10,7 @@ import net.minecraft.network.PacketByteBuf; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; + import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -23,12 +24,12 @@ public class TestUtils implements ModInitializer { public static final String MOD_ID = "testutils"; // Note: currently different from fabric.mod.json id public static final Logger LOGGER = LogManager.getLogger(MOD_ID); - public static final Identifier WEATHER_GAMERULE_SYNC = TestUtils.id("weather_sync"); - public static final Identifier WEATHER_GAMERULE_SYNC_REQUEST = TestUtils.id("weather_sync_request"); + public static final Identifier OPEN_BOOK_S2C = TestUtils.id("open_book"); + public static final Identifier WEATHER_GAMERULE_SYNC_S2C = TestUtils.id("weather_sync"); - public static final Identifier SET_TIME_PACKET_ID = TestUtils.id("set_time"); - public static final Identifier SET_RULE_PACKET_ID = TestUtils.id("set_rule"); - public static final Identifier SET_WEATHER_PACKET_ID = TestUtils.id("set_weather"); + public static final Identifier SET_TIME_C2S = TestUtils.id("set_time"); + public static final Identifier SET_RULE_C2S = TestUtils.id("set_rule"); + public static final Identifier SET_WEATHER_C2S = TestUtils.id("set_weather"); public static final short DO_DAYLIGHT_CYCLE_RULE = 1; public static final short DO_WEATHER_CYCLE_RULE = 2; @@ -60,27 +61,23 @@ public void onInitialize() { sendWeatherRule(handler.player); }); - ServerPlayNetworking.registerGlobalReceiver(WEATHER_GAMERULE_SYNC_REQUEST, (server, player, handler, buf, sender) -> { - sendWeatherRule(player); - }); - // client wants to set the time - ServerPlayNetworking.registerGlobalReceiver(SET_TIME_PACKET_ID, (server, player, handler, buf, responseSender) -> { + ServerPlayNetworking.registerGlobalReceiver(SET_TIME_C2S, (server, player, handler, buf, responseSender) -> { // make sure its not over 24000 long wantedTime = buf.getLong(0) % 24000; // Execute on the main thread server.execute(() -> { - ServerWorld world = (ServerWorld) player.world; + ServerWorld world = player.getServerWorld(); // set the time world.setTimeOfDay(wantedTime); }); }); // client wants to set the weather - ServerPlayNetworking.registerGlobalReceiver(SET_WEATHER_PACKET_ID, (server, player, handler, buf, responseSender) -> { + ServerPlayNetworking.registerGlobalReceiver(SET_WEATHER_C2S, (server, player, handler, buf, responseSender) -> { short weather = buf.getShort(0); - ServerWorld world = (ServerWorld) player.world; + ServerWorld world = player.getServerWorld(); // Execute on the main thread server.execute(() -> { @@ -93,10 +90,10 @@ public void onInitialize() { }); // client wants to set a rule (eg. freeze the time) - ServerPlayNetworking.registerGlobalReceiver(SET_RULE_PACKET_ID, (server, player, handler, buf, sender) -> { + ServerPlayNetworking.registerGlobalReceiver(SET_RULE_C2S, (server, player, handler, buf, sender) -> { short ruleID = buf.getShort(0); boolean value = buf.getBoolean(2); - ServerWorld world = (ServerWorld) player.world; + ServerWorld world = player.getServerWorld(); // Execute on the main thread server.execute(() -> { @@ -125,21 +122,26 @@ public void onInitialize() { }); } - public void broadcastWeatherRuleChange(MinecraftServer server, boolean value) { + public static void sendOpenBookPacket(ServerPlayerEntity player) { + PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); + ServerPlayNetworking.send(player, OPEN_BOOK_S2C, packet); + } + + public static void broadcastWeatherRuleChange(MinecraftServer server, boolean value) { PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); packet.writeBoolean(value); // Notify each player on the server about the weather gamerule update. server.getPlayerManager().getPlayerList().forEach(player -> { - ServerPlayNetworking.send(player, WEATHER_GAMERULE_SYNC, packet); + ServerPlayNetworking.send(player, WEATHER_GAMERULE_SYNC_S2C, packet); }); } - public void sendWeatherRule(ServerPlayerEntity player) { - ServerWorld world = (ServerWorld)player.world; + public static void sendWeatherRule(ServerPlayerEntity player) { + ServerWorld world = player.getServerWorld(); boolean doWeatherCycle = world.getGameRules().getBoolean(GameRules.DO_WEATHER_CYCLE); PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); packet.writeBoolean(doWeatherCycle); - ServerPlayNetworking.send(player, WEATHER_GAMERULE_SYNC, packet); + ServerPlayNetworking.send(player, WEATHER_GAMERULE_SYNC_S2C, packet); } } diff --git a/src/main/java/io/minepkg/testutils/TestUtilsClient.java b/src/main/java/io/minepkg/testutils/TestUtilsClient.java index 6c291e4..b222040 100644 --- a/src/main/java/io/minepkg/testutils/TestUtilsClient.java +++ b/src/main/java/io/minepkg/testutils/TestUtilsClient.java @@ -10,7 +10,13 @@ public class TestUtilsClient implements ClientModInitializer { @Override public void onInitializeClient() { - ClientPlayNetworking.registerGlobalReceiver(TestUtils.WEATHER_GAMERULE_SYNC, (client, clientPlayNetworkHandler, packet, packetSender) -> { + ClientPlayNetworking.registerGlobalReceiver(TestUtils.OPEN_BOOK_S2C, (client, clientPlayNetworkHandler, packet, packetSender) -> { + client.execute(() -> { + client.setScreen(new RuleBookScreen(new RuleBookGUI(client.world, client.player))); + }); + }); + + ClientPlayNetworking.registerGlobalReceiver(TestUtils.WEATHER_GAMERULE_SYNC_S2C, (client, clientPlayNetworkHandler, packet, packetSender) -> { boolean doWeatherCycle = packet.readBoolean(); client.execute(() -> { diff --git a/src/main/java/io/minepkg/testutils/gui/WGradient.java b/src/main/java/io/minepkg/testutils/gui/WGradient.java index bf89130..c1d4312 100644 --- a/src/main/java/io/minepkg/testutils/gui/WGradient.java +++ b/src/main/java/io/minepkg/testutils/gui/WGradient.java @@ -5,7 +5,7 @@ import io.github.cottonmc.cotton.gui.widget.data.Color.RGB; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; // Import DrawContext! public class WGradient extends WWidget { @@ -23,11 +23,11 @@ public boolean canResize() { @Environment(EnvType.CLIENT) @Override - public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { + public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) { // Changed to DrawContext! for (int yPos = 0; yPos < getHeight(); yPos++) { double percent = yPos / (double)getHeight(); RGB color = WGradient.interpolateColors(colorFrom, colorTo, percent); - ScreenDrawing.coloredRect(matrices, x, y+yPos, getWidth(), 1, color.toRgb()); + ScreenDrawing.coloredRect(context, x, y+yPos, getWidth(), 1, color.toRgb()); // Use 'context' } } @@ -38,4 +38,4 @@ public static RGB interpolateColors(RGB color1, RGB color2, double percent){ double b = (color2.getB() - color1.getB()) * percent + color1.getB(); return new RGB((int)a, (int)r, (int)g, (int)b); } -} +} \ No newline at end of file diff --git a/src/main/java/io/minepkg/testutils/gui/WSpriteButton.java b/src/main/java/io/minepkg/testutils/gui/WSpriteButton.java index 95e973a..338bbc1 100644 --- a/src/main/java/io/minepkg/testutils/gui/WSpriteButton.java +++ b/src/main/java/io/minepkg/testutils/gui/WSpriteButton.java @@ -3,8 +3,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import io.github.cottonmc.cotton.gui.client.ScreenDrawing; import io.github.cottonmc.cotton.gui.widget.WButton; -import io.minepkg.testutils.TestUtils; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.util.Identifier; public class WSpriteButton extends WButton { @@ -29,21 +28,21 @@ public void setSize(int x, int y) { } @Override - public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { + public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) { // Changed to DrawContext! boolean hovered = (mouseX>=0 && mouseY>=0 && mouseX=17" - }, - "suggests": { - "minepkg-companion": "*" - } + "name": "test-utils", + "description": "Makes mod testing easier. Currently lets you control time and weather without the fuzz.", + "authors": ["Filip Weiss"], + "contact": { + "homepage": "https://minepkg.io/projects/test-utils", + "sources": "https://github.com/minepkg/test-utils" + }, + "license": "MIT", + "icon": "assets/testutils/textures/item/rulebook.png", + "environment": "*", + "entrypoints": { + "main": ["io.minepkg.testutils.TestUtils"], + "client": ["io.minepkg.testutils.TestUtilsClient"] + }, + "depends": { + "fabricloader": "*", + "fabric": "*", + "minecraft": "${minecraft_version_range}", + "java": ">=${java_version}" + }, + "suggests": { + "minepkg-companion": "*" + } }