From a7045c4b15911c742534744d2faab38f2fda99f5 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Tue, 9 May 2023 13:33:17 +0700 Subject: [PATCH] use chipmunkmod .say well its the same code but whatever --- .../chipmunkmod/commands/SayCommand.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/land/chipmunk/chipmunkmod/commands/SayCommand.java b/src/main/java/land/chipmunk/chipmunkmod/commands/SayCommand.java index 42db2ae..0f18e46 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/commands/SayCommand.java +++ b/src/main/java/land/chipmunk/chipmunkmod/commands/SayCommand.java @@ -3,14 +3,12 @@ package land.chipmunk.chipmunkmod.commands; import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.CommandContext; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayNetworkHandler; - -import static com.mojang.brigadier.arguments.StringArgumentType.getString; -import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; -import static land.chipmunk.chipmunkmod.command.CommandManager.argument; import static land.chipmunk.chipmunkmod.command.CommandManager.literal; +import static land.chipmunk.chipmunkmod.command.CommandManager.argument; +import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; +import static com.mojang.brigadier.arguments.StringArgumentType.getString; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.text.Text; public class SayCommand { public static void register (CommandDispatcher dispatcher) { @@ -18,15 +16,14 @@ public class SayCommand { literal("say") .then( argument("message", greedyString()) - .executes(m -> say(m)) + .executes(SayCommand::say) ) ); } public static int say (CommandContext context) { - final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler(); - - networkHandler.sendChatMessage(getString(context, "message")); + final FabricClientCommandSource source = context.getSource(); + source.getClient().getNetworkHandler().sendChatMessage(getString(context, "message")); return Command.SINGLE_SUCCESS; }