diff --git a/src/main/java/land/chipmunk/chipmunkmod/mixin/CommandDispatcherMixin.java b/src/main/java/land/chipmunk/chipmunkmod/mixin/CommandDispatcherMixin.java new file mode 100644 index 0000000..40310fa --- /dev/null +++ b/src/main/java/land/chipmunk/chipmunkmod/mixin/CommandDispatcherMixin.java @@ -0,0 +1,24 @@ +package land.chipmunk.chipmunkmod.mixin; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.ParseResults; +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.context.CommandContextBuilder; +import com.mojang.brigadier.tree.CommandNode; +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; + +@Mixin(CommandDispatcher.class) +public class CommandDispatcherMixin { + @Inject(method = "parseNodes", at = @At("HEAD"), cancellable = true, /* important --> */ remap = false) + private void parseNodes (CommandNode node, StringReader originalReader, CommandContextBuilder contextSoFar, CallbackInfoReturnable> cir) { + // correct way to patch this? +// if (node.getRelevantNodes(originalReader).size() > 127) { +// cir.setReturnValue(new ParseResults<>(contextSoFar)); +// +// cir.cancel(); +// } + } +} diff --git a/src/main/java/land/chipmunk/chipmunkmod/mixin/TextSerializerMixin.java b/src/main/java/land/chipmunk/chipmunkmod/mixin/TextSerializerMixin.java index 1ec8529..44c72b1 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/mixin/TextSerializerMixin.java +++ b/src/main/java/land/chipmunk/chipmunkmod/mixin/TextSerializerMixin.java @@ -55,7 +55,7 @@ public class TextSerializerMixin { if (!overLimit) return; - cir.setReturnValue(Text.literal("Component is too big").formatted(Formatting.RED)); + cir.setReturnValue(Text.empty()); // just ignores it cir.cancel(); } diff --git a/src/main/resources/chipmunkmod.mixins.json b/src/main/resources/chipmunkmod.mixins.json index d20e865..a19ab15 100644 --- a/src/main/resources/chipmunkmod.mixins.json +++ b/src/main/resources/chipmunkmod.mixins.json @@ -22,7 +22,8 @@ "ClientConnectionAccessor", "PlayerListEntryAccessor", "SharedConstantsMixin", - "TextSerializerMixin" + "TextSerializerMixin", + "CommandDispatcherMixin" ], "injectors": { "defaultRequire": 1