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