diff --git a/src/main/java/land/chipmunk/chipmunkmod/mixin/NbtIoMixin.java b/src/main/java/land/chipmunk/chipmunkmod/mixin/NbtIoMixin.java new file mode 100644 index 0000000..aa775f0 --- /dev/null +++ b/src/main/java/land/chipmunk/chipmunkmod/mixin/NbtIoMixin.java @@ -0,0 +1,28 @@ +package land.chipmunk.chipmunkmod.mixin; + +import net.minecraft.nbt.*; +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 java.io.DataInput; +import java.io.IOException; + +@Mixin(NbtIo.class) +public class NbtIoMixin { + @Inject(method = "read(Ljava/io/DataInput;ILnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtElement;", at = @At("HEAD"), cancellable = true) + private static void read(DataInput input, int depth, NbtTagSizeTracker tracker, CallbackInfoReturnable cir) { + try { + byte b = input.readByte(); + if (b == 0) { + cir.setReturnValue(NbtEnd.INSTANCE); + } + + NbtString.skip(input); + cir.setReturnValue(NbtTypes.byId(b).read(input, depth, tracker)); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/land/chipmunk/chipmunkmod/mixin/StringHelperMixin.java b/src/main/java/land/chipmunk/chipmunkmod/mixin/StringHelperMixin.java index 4801f6e..dd5ce5c 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/mixin/StringHelperMixin.java +++ b/src/main/java/land/chipmunk/chipmunkmod/mixin/StringHelperMixin.java @@ -3,18 +3,18 @@ package land.chipmunk.chipmunkmod.mixin; import net.minecraft.util.StringHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(StringHelper.class) public class StringHelperMixin { - // totallynotskidded™ from meteor client - @ModifyArg(method = "truncateChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringHelper;truncate(Ljava/lang/String;IZ)Ljava/lang/String;")) - private static int truncateChat(int maxLength) { - return Integer.MAX_VALUE; + @Inject(method = "truncateChat", at = @At("HEAD"), cancellable = true) + private static void truncateChat (String text, CallbackInfoReturnable cir) { + cir.setReturnValue(text); } - @ModifyArg(method = "stripTextFormat", at = @At(value = "INVOKE", target = "Ljava/util/regex/Matcher;replaceAll(Ljava/lang/String;)Ljava/lang/String;")) - private static String stripTextFormat (String replacement) { - return replacement; + @Inject(method = "stripTextFormat", at = @At("HEAD"), cancellable = true) + private static void stripTextFormat(String text, CallbackInfoReturnable cir) { + cir.setReturnValue(text); } } diff --git a/src/main/resources/chipmunkmod.mixins.json b/src/main/resources/chipmunkmod.mixins.json index e6a2726..5b19f67 100644 --- a/src/main/resources/chipmunkmod.mixins.json +++ b/src/main/resources/chipmunkmod.mixins.json @@ -14,7 +14,8 @@ "MinecraftClientAccessor", "LightmapTextureManagerMixin", "DecoderHandlerMixin", - "StringHelperMixin" + "StringHelperMixin", + "NbtIoMixin" ], "injectors": { "defaultRequire": 1