From cc123614d76956677750c9e877799ad384f676de Mon Sep 17 00:00:00 2001 From: Naz Date: Tue, 21 May 2024 02:38:30 +0800 Subject: [PATCH] Update to 1.20.6 --- .github/workflows/gradle.yml | 4 ++-- .github/workflows/modrinth.yml | 4 ++-- build.gradle | 4 ++-- gradle.properties | 12 ++++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- .../mixin/PlayerEntityRendererMixin.java | 10 +++++----- .../nicknamer/client/NicknamerClient.kt | 9 +++++---- .../config/nickname/NicknameManager.kt | 17 ++++++++++++----- src/main/resources/fabric.mod.json | 4 ++-- 9 files changed, 37 insertions(+), 29 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 64bdfd4..0514fdb 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -15,10 +15,10 @@ jobs: with: submodules: true token: ${{ secrets.PAT_TOKEN }} - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' + java-version: '21' distribution: 'temurin' # Taken from https://github.com/CaffeineMC/sodium-fabric/blob/1.19.3/dev/.github/workflows/gradle.yml - name: Cache/Uncache diff --git a/.github/workflows/modrinth.yml b/.github/workflows/modrinth.yml index fd095f2..f64c4af 100644 --- a/.github/workflows/modrinth.yml +++ b/.github/workflows/modrinth.yml @@ -18,10 +18,10 @@ jobs: with: submodules: true token: ${{ secrets.PAT_TOKEN }} - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' + java-version: '21' distribution: 'temurin' # Taken from https://github.com/CaffeineMC/sodium-fabric/blob/1.19.3/dev/.github/workflows/gradle.yml - name: Cache/Uncache diff --git a/build.gradle b/build.gradle index 60edc40..7929eea 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.0-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' id 'org.jetbrains.kotlin.jvm' version '1.7.20' id "com.modrinth.minotaur" version "2.+" @@ -126,7 +126,7 @@ modrinth { versionNumber = "${project.mod_version}+${project.minecraft_version}" // You don't need to set this manually. Will fail if Modrinth has this version already versionType = "release" // This is the default -- can also be `beta` or `alpha` uploadFile = remapJar // With Loom, this MUST be set to `remapJar` instead of `jar`! - gameVersions = ["1.20.3", "1.20.4"] // Must be an array, even with only one version + gameVersions = ["1.20.5", "1.20.6"] // Must be an array, even with only one version loaders = ["fabric"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle dependencies { // A special DSL for creating dependencies // scope.type diff --git a/gradle.properties b/gradle.properties index b1b5d59..4b61464 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,17 +2,17 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.14.9 +minecraft_version=1.20.6 +yarn_mappings=1.20.6+build.2 +loader_version=0.15.10 # Mod Properties mod_version=1.1.3 maven_group=xyz.bluspring archives_base_name=Nicknamer # Dependencies # check this on https://modmuss50.me/fabric.html -fabric_version=0.93.1+1.20.4 +fabric_version=0.99.0+1.20.6 fabric_kotlin_version=1.8.5+kotlin.1.7.20 -modmenu_version=9.0.0 -cloth_config_version=13.0.121 \ No newline at end of file +modmenu_version=10.0.0-beta.1 +cloth_config_version=14.0.126 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fc..48c0a02 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/xyz/bluspring/nicknamer/mixin/PlayerEntityRendererMixin.java b/src/main/java/xyz/bluspring/nicknamer/mixin/PlayerEntityRendererMixin.java index 7bcfdeb..2db3afa 100644 --- a/src/main/java/xyz/bluspring/nicknamer/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/xyz/bluspring/nicknamer/mixin/PlayerEntityRendererMixin.java @@ -15,9 +15,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; import xyz.bluspring.nicknamer.Nicknamer; +import xyz.bluspring.nicknamer.config.ConfigManager; import xyz.bluspring.nicknamer.config.nickname.NicknameManager; import xyz.bluspring.nicknamer.config.pronouns.PronounManager; -import xyz.bluspring.nicknamer.config.ConfigManager; @Mixin(PlayerEntityRenderer.class) public abstract class PlayerEntityRendererMixin extends LivingEntityRenderer> { @@ -25,22 +25,22 @@ public PlayerEntityRendererMixin(EntityRendererFactory.Context ctx, PlayerEntity super(ctx, model, shadowRadius); } - @Inject(at = @At("HEAD"), method = "renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V") - public void appendPronouns(AbstractClientPlayerEntity player, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { + @Inject(at = @At("HEAD"), method = "renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IF)V") + public void appendPronouns(AbstractClientPlayerEntity player, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, float f, CallbackInfo ci) { if (PronounManager.INSTANCE.getPronouns().containsKey(player.getUuid())) { super.renderLabelIfPresent( player, PronounManager.INSTANCE.getPronounsText(player.getUuid()), matrixStack, vertexConsumerProvider, - i + i, f ); matrixStack.translate(0.0, (9.0F * 1.15F * 0.025F), 0.0); } } - @ModifyArgs(method = "renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;renderLabelIfPresent(Lnet/minecraft/entity/Entity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V")) + @ModifyArgs(method = "renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;renderLabelIfPresent(Lnet/minecraft/entity/Entity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IF)V")) public void changeText(Args args) { var player = (AbstractClientPlayerEntity) args.get(0); Text text = args.get(1); diff --git a/src/main/kotlin/xyz/bluspring/nicknamer/client/NicknamerClient.kt b/src/main/kotlin/xyz/bluspring/nicknamer/client/NicknamerClient.kt index 44a0044..af76e62 100644 --- a/src/main/kotlin/xyz/bluspring/nicknamer/client/NicknamerClient.kt +++ b/src/main/kotlin/xyz/bluspring/nicknamer/client/NicknamerClient.kt @@ -6,6 +6,7 @@ import net.fabricmc.api.ClientModInitializer import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource +import net.minecraft.command.CommandRegistryAccess import net.minecraft.command.argument.TextArgumentType import xyz.bluspring.nicknamer.commands.nick.* import xyz.bluspring.nicknamer.commands.pronouns.PronounsGetCommand @@ -20,12 +21,12 @@ import xyz.bluspring.nicknamer.config.pronouns.PronounManager class NicknamerClient : ClientModInitializer { override fun onInitializeClient() { - ClientCommandRegistrationCallback.EVENT.register { it, _ -> - registerCommands(it) + ClientCommandRegistrationCallback.EVENT.register { it, registryAccess -> + registerCommands(it, registryAccess) } } - private fun registerCommands(dispatcher: CommandDispatcher) { + private fun registerCommands(dispatcher: CommandDispatcher, registryAccess: CommandRegistryAccess) { dispatcher.register( ClientCommandManager .literal("nickc") @@ -58,7 +59,7 @@ class NicknamerClient : ClientModInitializer { .then( ClientCommandManager.argument( "nickname", - TextArgumentType.text() + TextArgumentType.text(registryAccess) ) .executes(NickSetRawCommand()) ) diff --git a/src/main/kotlin/xyz/bluspring/nicknamer/config/nickname/NicknameManager.kt b/src/main/kotlin/xyz/bluspring/nicknamer/config/nickname/NicknameManager.kt index 1540344..39db3fb 100644 --- a/src/main/kotlin/xyz/bluspring/nicknamer/config/nickname/NicknameManager.kt +++ b/src/main/kotlin/xyz/bluspring/nicknamer/config/nickname/NicknameManager.kt @@ -1,9 +1,9 @@ package xyz.bluspring.nicknamer.config.nickname -import com.google.gson.JsonArray -import com.google.gson.JsonObject -import com.google.gson.JsonParser +import com.google.gson.* +import com.mojang.serialization.JsonOps import net.minecraft.text.Text +import net.minecraft.text.TextCodecs import xyz.bluspring.nicknamer.Nicknamer import xyz.bluspring.nicknamer.config.ConfigManager import java.io.File @@ -15,6 +15,10 @@ object NicknameManager/*(val pathName: String)*/ { val nicknames = mutableMapOf() val disabled = mutableSetOf() + private val GSON = GsonBuilder() + .disableHtmlEscaping() + .create() + fun save() { if (!file.exists()) { if (!Nicknamer.configDir.exists()) @@ -27,7 +31,7 @@ object NicknameManager/*(val pathName: String)*/ { json.add("nicknames", JsonObject().apply { nicknames.forEach { (uuid, text) -> - addProperty(uuid.toString(), Text.Serialization.toJsonString(text)) + addProperty(uuid.toString(), GSON.toJson(TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, text).getOrThrow(::JsonParseException))) } }) @@ -48,7 +52,10 @@ object NicknameManager/*(val pathName: String)*/ { json.getAsJsonObject("nicknames").apply { entrySet().forEach { (uuid, text) -> - nicknames[UUID.fromString(uuid)] = Text.Serialization.fromJson(text.asString) ?: Text.of("no load") + nicknames[UUID.fromString(uuid)] = TextCodecs.CODEC.parse( + JsonOps.INSTANCE, + JsonParser.parseString(text.asString) + ).getOrThrow(::JsonParseException) ?: Text.of("no load") } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index accfa13..34202f7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,8 +30,8 @@ "depends": { "fabricloader": ">=0.14.9", "fabric": "*", - "minecraft": ">=1.20.3", + "minecraft": ">=1.20.5", "fabric-language-kotlin": "*", - "cloth-config": ">=13" + "cloth-config": ">=14" } }