diff --git a/src/main/java/net/kelsoncraft/test/TestCommands.java b/src/main/java/net/kelsoncraft/test/TestCommands.java index f970472..8ba5cb0 100644 --- a/src/main/java/net/kelsoncraft/test/TestCommands.java +++ b/src/main/java/net/kelsoncraft/test/TestCommands.java @@ -2,8 +2,15 @@ package net.kelsoncraft.test; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.kelsoncraft.test.util.Messages; +import net.minecraft.block.PlayerSkullBlock; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.CraftingInventory; +import net.minecraft.network.message.MessageType; +import net.minecraft.network.message.SentMessage; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; // https://www.reddit.com/r/fabricmc/comments/r3bd47/fabric_execute_commands/ @@ -15,6 +22,31 @@ public class TestCommands { public TestCommands() { } + + // I'm not sure how to use this. +// private String getPlayer() { +// +// PlayerEntity playerEntity = new PlayerEntity() { +// @Override +// public boolean isSpectator() { +// return false; +// } +// +// @Override +// public boolean isCreative() { +// return false; +// } +// } +// return ""; +// } + + // This may crash the server. +// PlayerEntity player; + // This might be fun. +// PlayerSkullBlock playerSkullBlock = new PlayerSkullBlock(); +// PlayerInventory playerInventory = new PlayerInventory(player); +// CraftingInventory craftingInventory = new CraftingInventory(); + // This works like this, now I know how to add commands to other classes, add them like this then initialize them in the main class. public static void init() { CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(CommandManager.literal("teleport") @@ -33,6 +65,48 @@ public class TestCommands { context.getSource().sendFeedback(() -> Text.literal(lightningMsg), false); return 1; }))); + + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(CommandManager.literal("test1") + .executes(context -> { +// // I don't know how to send a chat message with the below code. I need a message params +// SentMessage sentMessage = new SentMessage() { +// @Override +// public Text getContent() { +// return null; +// } +// +// @Override +// public void send(ServerPlayerEntity sender, boolean filterMaskEnabled, MessageType.Parameters params) { +// +// } +// }; +// context.getSource().sendChatMessage(sentMessage, false, ); + + + context.getSource().sendFeedback(() -> Text.literal("You will be exterminated!"), false); + return 1; + }))); + + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(CommandManager.literal("craft") + .executes(context -> { +// // I don't know how to send a chat message with the below code. I need a message params +// SentMessage sentMessage = new SentMessage() { +// @Override +// public Text getContent() { +// return null; +// } +// +// @Override +// public void send(ServerPlayerEntity sender, boolean filterMaskEnabled, MessageType.Parameters params) { +// +// } +// }; +// context.getSource().sendChatMessage(sentMessage, false, ); + + return 1; + }))); + + } }