From 8eb6b2cbe3b63456539b9c77363daf478910364a Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Thu, 14 Dec 2023 13:53:39 +0300 Subject: [PATCH] 1.20.4 port --- build.gradle | 6 +- gradle.properties | 8 +- gradlew.bat | 184 +++++++++--------- .../dev/hephaestus/glowcase/Glowcase.java | 2 +- .../hephaestus/glowcase/GlowcaseClient.java | 2 +- .../block/entity/TextBlockEntity.java | 4 +- .../glowcase/client/GlowcaseClientProxy.java | 2 +- .../screen/ingame/TextBlockEditScreen.java | 7 +- 8 files changed, 109 insertions(+), 106 deletions(-) diff --git a/build.gradle b/build.gradle index c7453ce..7eaff57 100644 --- a/build.gradle +++ b/build.gradle @@ -26,9 +26,9 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation include("eu.pb4:placeholder-api:2.1.2+1.20.1") - modCompileOnly "eu.pb4:polydex:1.0.0-beta.2.2+1.20.1" - modLocalRuntime "eu.pb4:polydex:1.0.0-beta.2.2+1.20.1" + modImplementation include("eu.pb4:placeholder-api:2.3.0+1.20.3") + modCompileOnly "eu.pb4:polydex:1.0.0+1.20.3-rc1" + modLocalRuntime "eu.pb4:polydex:1.0.0+1.20.3-rc1" } diff --git a/gradle.properties b/gradle.properties index 75bb0cc..403ca5a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.9 -loader_version=0.14.21 +minecraft_version=1.20.4 +yarn_mappings=1.20.4+build.3 +loader_version=0.15.1 # Mod Properties mod_version = 1.2.0 @@ -12,4 +12,4 @@ maven_group = dev.hephaestus archives_base_name = glowcase # Dependencies -fabric_version = 0.85.0+1.20.1 \ No newline at end of file +fabric_version = 0.91.2+1.20.4 \ No newline at end of file diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,92 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -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. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -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. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -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! -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 - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +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. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +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. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +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! +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 + +:omega diff --git a/src/main/java/dev/hephaestus/glowcase/Glowcase.java b/src/main/java/dev/hephaestus/glowcase/Glowcase.java index 65bc77f..348e655 100644 --- a/src/main/java/dev/hephaestus/glowcase/Glowcase.java +++ b/src/main/java/dev/hephaestus/glowcase/Glowcase.java @@ -103,7 +103,7 @@ private int sendMessage(CommandContext ctx) throws CommandS if (sender != null) { if (sender.getWorld().getBlockEntity(pos) instanceof MailboxBlockEntity mailbox) { - mailbox.addMessage(new MailboxBlockEntity.Message(sender.getUuid(), sender.getEntityName(), message)); + mailbox.addMessage(new MailboxBlockEntity.Message(sender.getUuid(), sender.getName().getString(), message)); ctx.getSource().sendFeedback(() -> Text.translatable("command.glowcase.message_sent"), false); return 0; } else { diff --git a/src/main/java/dev/hephaestus/glowcase/GlowcaseClient.java b/src/main/java/dev/hephaestus/glowcase/GlowcaseClient.java index fd6de43..a6d342f 100644 --- a/src/main/java/dev/hephaestus/glowcase/GlowcaseClient.java +++ b/src/main/java/dev/hephaestus/glowcase/GlowcaseClient.java @@ -39,7 +39,7 @@ public void onInitializeClient() { HudRenderCallback.EVENT.register((context, tickDelta) -> { MinecraftClient client = MinecraftClient.getInstance(); - if (client.world != null && client.crosshairTarget instanceof BlockHitResult hitResult && client.world.getBlockEntity(hitResult.getBlockPos()) instanceof MailboxBlockEntity mailbox && mailbox.messageCount() > 0 && mailbox.owner().equals(client.getSession().getProfile().getId())) { + if (client.world != null && client.crosshairTarget instanceof BlockHitResult hitResult && client.world.getBlockEntity(hitResult.getBlockPos()) instanceof MailboxBlockEntity mailbox && mailbox.messageCount() > 0 && mailbox.owner().equals(client.getSession().getUuidOrNull())) { Window window = client.getWindow(); TextRenderer textRenderer = client.textRenderer; MailboxBlockEntity.Message message = mailbox.getMessage(); diff --git a/src/main/java/dev/hephaestus/glowcase/block/entity/TextBlockEntity.java b/src/main/java/dev/hephaestus/glowcase/block/entity/TextBlockEntity.java index c673c86..5ba8979 100644 --- a/src/main/java/dev/hephaestus/glowcase/block/entity/TextBlockEntity.java +++ b/src/main/java/dev/hephaestus/glowcase/block/entity/TextBlockEntity.java @@ -55,7 +55,7 @@ public void writeNbt(NbtCompound tag) { NbtList lines = tag.getList("lines", 8); for (MutableText text : this.lines) { - lines.add(NbtString.of(Text.Serializer.toJson(text))); + lines.add(NbtString.of(Text.Serialization.toJsonString(text))); } tag.put("lines", lines); @@ -77,7 +77,7 @@ public void readNbt(NbtCompound tag) { for (NbtElement line : lines) { if (line.getType() == NbtElement.END_TYPE) break; - this.lines.add(Text.Serializer.fromJson(line.asString())); + this.lines.add(Text.Serialization.fromJson(line.asString())); } this.renderDirty = true; diff --git a/src/main/java/dev/hephaestus/glowcase/client/GlowcaseClientProxy.java b/src/main/java/dev/hephaestus/glowcase/client/GlowcaseClientProxy.java index 4c0c34c..9febda3 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/GlowcaseClientProxy.java +++ b/src/main/java/dev/hephaestus/glowcase/client/GlowcaseClientProxy.java @@ -23,7 +23,7 @@ public void openHyperlinkBlockEditScreen(BlockPos pos) { @Override public void openUrlWithConfirmation(String url) { - ConfirmLinkScreen.open(url, MinecraftClient.getInstance().currentScreen, false); + ConfirmLinkScreen.open(MinecraftClient.getInstance().currentScreen, url); } @Override diff --git a/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/TextBlockEditScreen.java b/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/TextBlockEditScreen.java index 2f1fad6..1d78995 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/TextBlockEditScreen.java +++ b/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/TextBlockEditScreen.java @@ -2,6 +2,7 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.serialization.DataResult; import dev.hephaestus.glowcase.block.entity.TextBlockEntity; import dev.hephaestus.glowcase.networking.GlowcaseClientNetworking; import net.minecraft.client.MinecraftClient; @@ -22,6 +23,8 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import java.util.Optional; + //TODO: multi-character selection at some point? it may be a bit complex but it'd be nice @Environment(EnvType.CLIENT) public class TextBlockEditScreen extends GlowcaseScreen { @@ -94,8 +97,8 @@ public void init() { this.colorEntryWidget = new TextFieldWidget(this.client.textRenderer, 280 + innerPadding * 2, 0, 50, 20, Text.empty()); this.colorEntryWidget.setText("#" + Integer.toHexString(this.textBlockEntity.color & 0x00FFFFFF)); this.colorEntryWidget.setChangedListener(string -> { - TextColor color = TextColor.parse(this.colorEntryWidget.getText()); - this.textBlockEntity.color = color == null ? 0xFFFFFFFF : color.getRgb() | 0xFF000000; + Optional color = TextColor.parse(this.colorEntryWidget.getText()).result(); + this.textBlockEntity.color = color.map(textColor -> textColor.getRgb() | 0xFF000000).orElse(0xFFFFFFFF); this.textBlockEntity.renderDirty = true; });