From df10182a7a444e0bb9c72d4455f9f83f473fb729 Mon Sep 17 00:00:00 2001 From: pomchom Date: Thu, 21 Dec 2023 23:46:20 -0500 Subject: [PATCH] fix title screen Resource Packs crash --- src/main/java/io/github/homchom/recode/Main.java | 2 +- .../feature/visual/BuiltInResourcePacks.kt | 16 +++++++++------- .../feature/visual/ExpressionHighlighting.kt | 1 + .../recode/ui/text/MiniMessageHighlighter.kt | 3 +-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/homchom/recode/Main.java b/src/main/java/io/github/homchom/recode/Main.java index 2b002c0bb..c2f848085 100644 --- a/src/main/java/io/github/homchom/recode/Main.java +++ b/src/main/java/io/github/homchom/recode/Main.java @@ -5,7 +5,7 @@ import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; // keep this file as a .java file! -public class Main implements ClientModInitializer, PreLaunchEntrypoint { +public final class Main implements ClientModInitializer, PreLaunchEntrypoint { @Override public void onInitializeClient() { Recode.INSTANCE.initialize(); 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 3919eec10..e05054742 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,10 @@ import io.github.homchom.recode.feature.feature import io.github.homchom.recode.id import io.github.homchom.recode.render.IntegralColor import io.github.homchom.recode.render.toColor -import io.github.homchom.recode.ui.text.style -import io.github.homchom.recode.ui.text.text -import io.github.homchom.recode.ui.text.toVanilla +import io.github.homchom.recode.ui.text.VanillaComponent import net.fabricmc.fabric.api.resource.ResourceManagerHelper import net.fabricmc.fabric.api.resource.ResourcePackActivationType +import net.minecraft.network.chat.Style val FBuiltInResourcePacks = feature("Built-in Resource Packs") { registerBuiltInResourcePack("better_unicode", 0x6770ff.toColor()) @@ -21,13 +20,16 @@ private fun registerBuiltInResourcePack( displayColor: IntegralColor, 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(Style.EMPTY.withColor(displayColor.toInt())) + ) + ResourceManagerHelper.registerBuiltinResourcePack( id(id), Recode, - text { - literal("[$MOD_ID] ") - translate("resourcePack.recode.$id", style().color(displayColor)) - }.toVanilla(), + packDescription, activationType ) } \ No newline at end of file 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 f8d9f5a4f..4137401a7 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 @@ -116,6 +116,7 @@ class ExpressionHighlighter { try { miniMessage.deserialize(string).toFormattedCharSequence() } catch (e: Exception) { + // https://github.com/KyoriPowered/adventure/issues/1011 null } } else null 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 9c616decd..489a69e6b 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 @@ -114,8 +114,7 @@ class MiniMessageHighlighter(private val standardTags: TagResolver) { val root = try { instance.deserializeToTree(input) } catch (e: Exception) { - // highlight red for exceptional parses, such as unclosed double quotes - // TODO: something better after ui update? + // https://github.com/KyoriPowered/adventure/issues/1011 return literalText(input, style().red()) } buildNewInput(root)