Creating Commands
Commands can be created using a dedicated Command Class and the @Command
Annotation.
@Command("foo")
public static class TestCommand {
@Execute
public boolean runsWhenCommandIsExecuted(@Sender CommandSourceStack sender) {
sender.sendSystemMessage(RESPONSE);
return true;
}
}
Registration
Every command classes must then be registered using the CommandRegistry.registerCommand
method.
CommandRegistry.registerCommand(TestCommand.class);
- Architectury
- Fabric
- NeoForge
This should be done in the common package at entrypoint invocation (In fabric the ModInitializer#onInitialize
and on NeoForge the mod constructor).
This should be done in the ModInitializer#onInitialize
method.
This should be done in the mod constructor.