use chipmunkmod .say

well its the same code but whatever
This commit is contained in:
Chayapak 2023-05-09 13:33:17 +07:00
parent 3163709546
commit a7045c4b15

View file

@ -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<FabricClientCommandSource> 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<FabricClientCommandSource> 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;
}