From 53c27612b25ac1442ae8c82cf7c383b650de6186 Mon Sep 17 00:00:00 2001 From: RedVortex <58099979+RedVortexDev@users.noreply.github.com> Date: Tue, 26 Mar 2024 22:03:21 +0200 Subject: [PATCH 1/5] remove try-catch when deserializing (update adventure) https://github.com/KyoriPowered/adventure/issues/1011 was fixed - no need to try-catch anymore (update adventure accordingly) --- gradle.properties | 2 +- .../recode/feature/visual/ExpressionHighlighting.kt | 7 +------ .../homchom/recode/ui/text/MiniMessageHighlighter.kt | 7 +------ 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index 82b60955..2f761e94 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ flkVersion = 1.10.19+kotlin.1.9.23 # required dependency mods required.adventure-platform-fabric.artifact = net.kyori:adventure-platform-fabric -required.adventure-platform-fabric.version = 5.11.0 +required.adventure-platform-fabric.version = 5.12.0 required.adventure-platform-fabric.versionSpec = ~ required.libgui.artifact = io.github.cottonmc:LibGui diff --git a/src/main/java/io/github/homchom/recode/feature/visual/ExpressionHighlighting.kt b/src/main/java/io/github/homchom/recode/feature/visual/ExpressionHighlighting.kt index 04c7f9a3..1f752138 100644 --- a/src/main/java/io/github/homchom/recode/feature/visual/ExpressionHighlighting.kt +++ b/src/main/java/io/github/homchom/recode/feature/visual/ExpressionHighlighting.kt @@ -114,12 +114,7 @@ class ExpressionHighlighter { val text = builder.build().toFormattedCharSequence(false) val preview = if (parseMiniMessage) { - try { - miniMessage.deserialize(string).toFormattedCharSequence() - } catch (e: Exception) { - // https://github.com/KyoriPowered/adventure/issues/1011 - null - } + miniMessage.deserialize(string).toFormattedCharSequence() } else null return HighlightedExpression(text, preview) } diff --git a/src/main/java/io/github/homchom/recode/ui/text/MiniMessageHighlighter.kt b/src/main/java/io/github/homchom/recode/ui/text/MiniMessageHighlighter.kt index 117473c3..6d37018f 100644 --- a/src/main/java/io/github/homchom/recode/ui/text/MiniMessageHighlighter.kt +++ b/src/main/java/io/github/homchom/recode/ui/text/MiniMessageHighlighter.kt @@ -111,12 +111,7 @@ class MiniMessageHighlighter(private val standardTags: TagResolver) { } } - val root = try { - instance.deserializeToTree(input) - } catch (e: Exception) { - // https://github.com/KyoriPowered/adventure/issues/1011 - return literalText(input, style().red()).asComponent() - } + val root = instance.deserializeToTree(input) buildNewInput(root) return instance.deserialize(newInput.toString()) } From 077b5d4f3112f129e047c729a326410f7bf187ee Mon Sep 17 00:00:00 2001 From: RedVortex <58099979+RedVortexDev@users.noreply.github.com> Date: Tue, 26 Mar 2024 23:33:54 +0200 Subject: [PATCH 2/5] remove more adventure workarounds issues got fixed --- .../recode/feature/visual/BuiltInResourcePacks.kt | 15 ++++++++------- .../homchom/recode/render/StaticSkinRender.kt | 4 ---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt b/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt index 658a3c7c..afe195fe 100644 --- a/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt +++ b/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt @@ -6,10 +6,11 @@ import io.github.homchom.recode.feature.AddsFeature import io.github.homchom.recode.feature.registerFeature import io.github.homchom.recode.id import io.github.homchom.recode.render.RGB -import io.github.homchom.recode.ui.text.VanillaComponent -import io.github.homchom.recode.ui.text.VanillaStyle +import io.github.homchom.recode.ui.text.toVanilla import net.fabricmc.fabric.api.resource.ResourceManagerHelper import net.fabricmc.fabric.api.resource.ResourcePackActivationType +import net.kyori.adventure.text.Component +import net.kyori.adventure.text.format.TextColor @OptIn(AddsFeature::class) object FBuiltInResourcePacks { @@ -24,16 +25,16 @@ object FBuiltInResourcePacks { displayColor: RGB, activationType: ResourcePackActivationType = ResourcePackActivationType.DEFAULT_ENABLED ) { - // https://github.com/KyoriPowered/adventure-platform-fabric/issues/122 - val packDescription = VanillaComponent.literal("[$MOD_ID] ") - .append(VanillaComponent.translatable("resourcePack.recode.$id") - .withStyle(VanillaStyle.EMPTY.withColor(displayColor.hex)) + + val packDescription: Component = Component.text("[$MOD_ID] ") + .append(Component.translatable("resourcePack.recode.$id") + .color(TextColor.color(displayColor.hex)) ) ResourceManagerHelper.registerBuiltinResourcePack( id(id), Recode, - packDescription, + packDescription.toVanilla(), activationType ) } diff --git a/src/main/java/io/github/homchom/recode/render/StaticSkinRender.kt b/src/main/java/io/github/homchom/recode/render/StaticSkinRender.kt index 50106533..65014eb1 100644 --- a/src/main/java/io/github/homchom/recode/render/StaticSkinRender.kt +++ b/src/main/java/io/github/homchom/recode/render/StaticSkinRender.kt @@ -1,7 +1,6 @@ package io.github.homchom.recode.render import com.mojang.authlib.GameProfile -import net.kyori.adventure.identity.Identity import net.minecraft.Util import net.minecraft.client.Minecraft import net.minecraft.client.player.RemotePlayer @@ -17,7 +16,4 @@ class StaticSkinRender(client: Minecraft, private val skin: PlayerSkin) : Remote ) { override fun getSkin() = skin override fun isModelPartShown(part: PlayerModelPart) = true - - // https://github.com/KyoriPowered/adventure-platform-fabric/issues/120 - override fun identity() = gameProfile as Identity } \ No newline at end of file From 49e7cff9424d5f5b5dc0eab475a3f5a79e82c51a Mon Sep 17 00:00:00 2001 From: RedVortex <58099979+RedVortexDev@users.noreply.github.com> Date: Tue, 26 Mar 2024 23:34:05 +0200 Subject: [PATCH 3/5] bump better unicode pack format --- src/main/resources/resourcepacks/better_unicode/pack.mcmeta | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/resourcepacks/better_unicode/pack.mcmeta b/src/main/resources/resourcepacks/better_unicode/pack.mcmeta index 575ac7f1..08d7494b 100644 --- a/src/main/resources/resourcepacks/better_unicode/pack.mcmeta +++ b/src/main/resources/resourcepacks/better_unicode/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 18, + "pack_format": 22, "description": "vanilla-style unicode symbols.\n§8BetterUnicode by Electrosolt" } } From df604d7599a91e6c889914bf7f305052139094dd Mon Sep 17 00:00:00 2001 From: RedVortex <58099979+RedVortexDev@users.noreply.github.com> Date: Tue, 26 Mar 2024 23:42:07 +0200 Subject: [PATCH 4/5] revert type safety in packDescription --- .../homchom/recode/feature/visual/BuiltInResourcePacks.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt b/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt index afe195fe..29fcd135 100644 --- a/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt +++ b/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt @@ -26,7 +26,7 @@ object FBuiltInResourcePacks { activationType: ResourcePackActivationType = ResourcePackActivationType.DEFAULT_ENABLED ) { - val packDescription: Component = Component.text("[$MOD_ID] ") + val packDescription = Component.text("[$MOD_ID] ") .append(Component.translatable("resourcePack.recode.$id") .color(TextColor.color(displayColor.hex)) ) From f209d7ac3cb62fc9ac7ab9210e39a36a4e613d77 Mon Sep 17 00:00:00 2001 From: RedVortex <58099979+RedVortexDev@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:35:00 +0200 Subject: [PATCH 5/5] use recode's text() function instead --- .../feature/visual/BuiltInResourcePacks.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt b/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt index 29fcd135..b1967511 100644 --- a/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt +++ b/src/main/java/io/github/homchom/recode/feature/visual/BuiltInResourcePacks.kt @@ -6,11 +6,11 @@ import io.github.homchom.recode.feature.AddsFeature import io.github.homchom.recode.feature.registerFeature import io.github.homchom.recode.id import io.github.homchom.recode.render.RGB -import io.github.homchom.recode.ui.text.toVanilla +import io.github.homchom.recode.ui.text.style +import io.github.homchom.recode.ui.text.text +import io.github.homchom.recode.ui.text.toVanillaComponent import net.fabricmc.fabric.api.resource.ResourceManagerHelper import net.fabricmc.fabric.api.resource.ResourcePackActivationType -import net.kyori.adventure.text.Component -import net.kyori.adventure.text.format.TextColor @OptIn(AddsFeature::class) object FBuiltInResourcePacks { @@ -26,15 +26,15 @@ object FBuiltInResourcePacks { activationType: ResourcePackActivationType = ResourcePackActivationType.DEFAULT_ENABLED ) { - val packDescription = Component.text("[$MOD_ID] ") - .append(Component.translatable("resourcePack.recode.$id") - .color(TextColor.color(displayColor.hex)) - ) + val packDescription = text { + literal("[$MOD_ID] ") + translate("resourcePack.recode.$id", style().color(displayColor)) + } ResourceManagerHelper.registerBuiltinResourcePack( id(id), Recode, - packDescription.toVanilla(), + packDescription.toVanillaComponent(), activationType ) }