From 3ea9fb7af0c31496ec1f02fce998bbafc1e6a4c2 Mon Sep 17 00:00:00 2001 From: rugmj Date: Thu, 4 Jan 2024 12:25:52 +0000 Subject: [PATCH 1/2] reverts itembindmixin --- .../redstonetools/mixin/features/ItemBindMixin.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/tools/redstone/redstonetools/mixin/features/ItemBindMixin.java b/src/main/java/tools/redstone/redstonetools/mixin/features/ItemBindMixin.java index 085a813c..0cad09fd 100644 --- a/src/main/java/tools/redstone/redstonetools/mixin/features/ItemBindMixin.java +++ b/src/main/java/tools/redstone/redstonetools/mixin/features/ItemBindMixin.java @@ -53,7 +53,7 @@ private boolean tryToExecuteNBTCommand(Hand hand, World world) { NbtCompound nbt = getNbt(); if (nbt == null || !nbt.contains("command")) return false; NbtString command = (NbtString) nbt.get("command"); - MinecraftClient.getInstance().getNetworkHandler().sendChatMessage(command.asString()); + MinecraftClient.getInstance().getNetworkHandler().sendChatCommand(command.asString()); return true; } @@ -61,11 +61,11 @@ private boolean tryToExecuteNBTCommand(Hand hand, World world) { @Mixin(ClientPlayNetworkHandler.class) - private abstract static class PlayerMixin { + private abstract static class NetworkHandlerMixin { - @Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true) + @Inject(method = "sendChatCommand", at = @At("HEAD"), cancellable = true) public void injectCommand(String message, CallbackInfo ci) { - if (!message.startsWith("/") || !ItemBindFeature.waitingForCommand) return; + if (!ItemBindFeature.waitingForCommand) return; Feedback addCommandFeedback = ItemBindFeature.addCommand(message); if (addCommandFeedback != null) { From 61cdc1de42dc6edaf913cfee878a421148e25ac7 Mon Sep 17 00:00:00 2001 From: rugmj Date: Thu, 4 Jan 2024 12:28:48 +0000 Subject: [PATCH 2/2] fixes CommandException errors --- .../redstonetools/features/commands/MinSelectionFeature.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/tools/redstone/redstonetools/features/commands/MinSelectionFeature.java b/src/main/java/tools/redstone/redstonetools/features/commands/MinSelectionFeature.java index c35adc29..70d9975b 100644 --- a/src/main/java/tools/redstone/redstonetools/features/commands/MinSelectionFeature.java +++ b/src/main/java/tools/redstone/redstonetools/features/commands/MinSelectionFeature.java @@ -2,6 +2,7 @@ import com.google.auto.service.AutoService; +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import tools.redstone.redstonetools.features.AbstractFeature; import tools.redstone.redstonetools.features.Feature; import tools.redstone.redstonetools.features.feedback.Feedback; @@ -99,7 +100,7 @@ private void minimiseSelection(World selectionWorld, Region selection) try { selection.contract(changes.toArray(new BlockVector3[changes.size()])); } catch (RegionOperationException e) { - throw new net.minecraft.command.CommandException(Text.of("There was an error modifying the region.")); + throw new SimpleCommandExceptionType(Text.of("There was an error modifying the region.")).create(); } if (!finished)