use chipmunkmod .say
well its the same code but whatever
This commit is contained in:
parent
3163709546
commit
a7045c4b15
1 changed files with 8 additions and 11 deletions
|
@ -3,14 +3,12 @@ package land.chipmunk.chipmunkmod.commands;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
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.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 class SayCommand {
|
||||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||||
|
@ -18,15 +16,14 @@ public class SayCommand {
|
||||||
literal("say")
|
literal("say")
|
||||||
.then(
|
.then(
|
||||||
argument("message", greedyString())
|
argument("message", greedyString())
|
||||||
.executes(m -> say(m))
|
.executes(SayCommand::say)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int say (CommandContext<FabricClientCommandSource> context) {
|
public static int say (CommandContext<FabricClientCommandSource> context) {
|
||||||
final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
|
final FabricClientCommandSource source = context.getSource();
|
||||||
|
source.getClient().getNetworkHandler().sendChatMessage(getString(context, "message"));
|
||||||
networkHandler.sendChatMessage(getString(context, "message"));
|
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue