Skip to content

Commit

Permalink
Merge pull request #353 from RUGMJ/rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
RUGMJ authored Jan 4, 2024
2 parents 09dbb75 + 61cdc1d commit 1428035
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ 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;
}
}


@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) {
Expand Down

0 comments on commit 1428035

Please sign in to comment.