Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
fix title screen Resource Packs crash
Browse files Browse the repository at this point in the history
  • Loading branch information
homchom committed Dec 22, 2023
1 parent ffbe0d5 commit df10182
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/github/homchom/recode/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class ExpressionHighlighter {
try {
miniMessage.deserialize(string).toFormattedCharSequence()
} catch (e: Exception) {
// https://github.com/KyoriPowered/adventure/issues/1011
null
}
} else null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit df10182

Please sign in to comment.