Skip to main content

CommandEvents

CommandEvents is how bundles add commands. The callback receives an event with the command dispatcher; register Brigadier commands on it.

Register

MethodWhen
register { event -> ... }Called on the server with event.getDispatcher().
registerClient { event -> ... }Called on the client with the client dispatcher.

Example

CommandEvents.register { event ->
def dispatcher = event.getDispatcher()
dispatcher.register(
Commands.literal("hello")
.executes { ctx ->
ctx.getSource().sendSuccess(
Component.literal("Hello from the bundle!"), false)
Command.SINGLE_SUCCESS
})
}