From 62a6960b53ed2a3c05412160b41e749d6302c64c Mon Sep 17 00:00:00 2001 From: ShowierData9978 Date: Fri, 26 Jul 2024 22:03:44 -0500 Subject: [PATCH] Feat: Overhaul the commands em --- .../tech/showierdata/pickaxe/Constants.java | 3 + .../tech/showierdata/pickaxe/Pickaxe.java | 57 +++++++++++++++---- .../mixin/ClientPlayNetworkHandlerMixin.java | 20 ++++++- 3 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/main/java/tech/showierdata/pickaxe/Constants.java b/src/main/java/tech/showierdata/pickaxe/Constants.java index e637258..691bdd2 100644 --- a/src/main/java/tech/showierdata/pickaxe/Constants.java +++ b/src/main/java/tech/showierdata/pickaxe/Constants.java @@ -1,5 +1,6 @@ package tech.showierdata.pickaxe; +import net.fabricmc.loader.impl.lib.sat4j.core.Vec; import net.minecraft.util.math.Vec3d; public class Constants { @@ -8,6 +9,8 @@ public class Constants { public static final Vec3d Spawn = new Vec3d(7085, 200, 4115); + public static final Vec3d WahDoor = new Vec3d(64, 0, 77); + public static final int PLOT_ID = 50644; public static final String SERVER_IP = "mcdiamondfire.com"; diff --git a/src/main/java/tech/showierdata/pickaxe/Pickaxe.java b/src/main/java/tech/showierdata/pickaxe/Pickaxe.java index 1973b24..66b9672 100644 --- a/src/main/java/tech/showierdata/pickaxe/Pickaxe.java +++ b/src/main/java/tech/showierdata/pickaxe/Pickaxe.java @@ -78,17 +78,20 @@ public static Pickaxe getInstance() { public static PickaxeCommand[] getCommands() { return new PickaxeCommand[] { new PickaxeCommand("help", - "This command! (Added by pickaxe mod)", + "This command! (Added by Pickaxe Mod)", new String[]{}, new HelpCommandController() ), - - new PickaxeCommand("itemlock", "Locks your held item", new String[] {}, new PassthroughCommand()), - new PickaxeCommand("pay", "Pay's the specified person the amount specified", new String[] { - "[user]", - "[amount]" - }, new PassthroughCommand()), + new PickaxeCommand("lockitem", + "Locks your held item", + new String[] {}, + new PassthroughCommand() + ), + new PickaxeCommand("pay", "Pay's the specified person the amount specified", + new String[] {"[user]", "[amount]" }, + new PassthroughCommand() + ), new PickaxeCommand("up", "Teleports you to the surface", new String[] {}, @@ -104,9 +107,43 @@ public static PickaxeCommand[] getCommands() { new String[] {"[color]"}, new PassthroughCommand() ), - + new PickaxeCommand("item", + "Sends the item you are holding in chat", + new String[] {"[text] "}, + new PassthroughCommand() + ), + new PickaxeCommand("title", + "Changes the name of a notebook", + new String[] {"[name]"}, + new PassthroughCommand() + ), + new PickaxeCommand("backup", + "Backs your inventory up! Make sure to run often.", + new String[] { }, + new PassthroughCommand() + ), + new PickaxeCommand("ach", + "Opens the achievement menu!", + new String[] { }, + new PassthroughCommand() + ), + new PickaxeCommand("trash", + "Opens a trash can inventory (does the same thing as offhand while in inventory)", + new String[] { }, + new PassthroughCommand() + ), + new PickaxeCommand("wah", + "Opens a shop for your WAH points.", + new String[] {}, + new PassthroughCommand() + ), + new PickaxeCommand("pay", + "Pays a user", + new String[]{"[username]"}, + new PassthroughCommand() + ), new PickaxeCommand("wiki", - "Sends a link to the wiki (Added by Pickaxe Mod)", + "Sends the link to the wiki (Added by Pickaxe Mod)", new String[] {}, (name, args) -> { MinecraftClient client = MinecraftClient.getInstance(); @@ -358,8 +395,6 @@ private void drawMDT(DrawContext context, TextRenderer renderer) { context.drawTextWithShadow(renderer, Texts.join(texts, Text.literal(" ")), 5, y, Colors.WHITE); - // Sounds - //prepSounds(client, time); } private void register_callbacks() { diff --git a/src/main/java/tech/showierdata/pickaxe/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/tech/showierdata/pickaxe/mixin/ClientPlayNetworkHandlerMixin.java index 5ee0be7..e486a08 100644 --- a/src/main/java/tech/showierdata/pickaxe/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/tech/showierdata/pickaxe/mixin/ClientPlayNetworkHandlerMixin.java @@ -30,6 +30,8 @@ public abstract class ClientPlayNetworkHandlerMixin { @Shadow public abstract void sendChatCommand(String message); + @Shadow public abstract void sendChatMessage(String content); + @Unique private boolean inLoop = false; @@ -56,7 +58,8 @@ private void onTick(CallbackInfo info) { @Inject(at = @At("HEAD"), method = "sendChatMessage", cancellable = true) private void sendMessage(String chatText, CallbackInfo info) { MinecraftClient client = MinecraftClient.getInstance(); - if (!Pickaxe.getInstance().isInPickaxe()) { + Pickaxe pick = Pickaxe.getInstance(); + if (!pick.getInstance().isInPickaxe()) { return; } if (chatText.startsWith("@") && !inLoop) { @@ -66,18 +69,29 @@ private void sendMessage(String chatText, CallbackInfo info) { inLoop = true; + Boolean flag = false; + + for (PickaxeCommand pickaxeCommand : Pickaxe.getInstance().commands) { if (!Objects.equals(pickaxeCommand.name, command.get(0))) { continue; } - + flag = true; pickaxeCommand.handler.use(command.get(0), command.subList(1, command.size())); + break; } + inLoop = false; - info.cancel(); + if (!pick.rel_spawn.isInRange(Constants.WahDoor, 6)) { + if (!flag) + client.player.sendMessage(Text.literal(command.get(0) + " is an invalid command! If you think this is wrong, " + + "\n disable the mod, check, then report to ShowierData9978")); + info.cancel(); + + } } }