From 7afcc606feb041df1eb16d7833a2c10ca15fd8fe Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:12:59 +0700 Subject: [PATCH] fix extra crash i did how blackilykat did it lol --- .../chipmunk/chipmunkmod/mixin/TextMixin.java | 26 +++++++++++++++++++ src/main/resources/chipmunkmod.mixins.json | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/main/java/land/chipmunk/chipmunkmod/mixin/TextMixin.java diff --git a/src/main/java/land/chipmunk/chipmunkmod/mixin/TextMixin.java b/src/main/java/land/chipmunk/chipmunkmod/mixin/TextMixin.java new file mode 100644 index 0000000..c5e1d08 --- /dev/null +++ b/src/main/java/land/chipmunk/chipmunkmod/mixin/TextMixin.java @@ -0,0 +1,26 @@ +package land.chipmunk.chipmunkmod.mixin; + +import net.minecraft.text.StringVisitable; +import net.minecraft.text.Style; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.Iterator; +import java.util.Optional; + +@Mixin(Text.class) +public interface TextMixin { + @Inject(method = "visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text;visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) + private void visit (StringVisitable.StyledVisitor styledVisitor, Style style, CallbackInfoReturnable> cir, Style style2, Optional optional, Iterator var5, Text text) { + if (text == null) cir.setReturnValue(Optional.empty()); + } + + @Inject(method = "visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text;visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) + private void visit (StringVisitable.Visitor visitor, CallbackInfoReturnable> cir, Optional optional, Iterator var3, Text text) { + if (text == null) cir.setReturnValue(Optional.empty()); + } +} diff --git a/src/main/resources/chipmunkmod.mixins.json b/src/main/resources/chipmunkmod.mixins.json index c6bbf21..1e466e6 100644 --- a/src/main/resources/chipmunkmod.mixins.json +++ b/src/main/resources/chipmunkmod.mixins.json @@ -20,7 +20,8 @@ "KeyboardInputMixin", "ElderGuardianAppearanceParticleMixin", "IdentifierMixin", - "DecoratedPotBlockEntitySherdsMixin" + "DecoratedPotBlockEntitySherdsMixin", + "TextMixin" ], "injectors": { "defaultRequire": 1