Package-level declarations

Utilities for command registration

Command registration

Automatic registration (Recommended)

Commands created using the command or clientCommand builder function will be registered automatically if called during initialization of your mod.

Note: this is only the case if the register parameter is set to true, which is the default

Example for automatic registration

First create the command somewhere

val myCommand = command("mycommand") { }

If this value will be initialized during the startup phase of your mod, you are done.

Otherwise, you can register the command by mentioning it in the entrypoint of your mod

fun init() {
myCommand // not needed, if the value is initialized anyways
}

Manual registration

If you need to register it manually, call the setupRegistrationCallback (server-side) or register (client-side) function by yourself.

Example for manual registration

First create the command somewhere

// note that register is set to false
val myCommand = command("mycommand", register = false) { }

After that, you can register the command by manually calling the registration function

fun init() {
myCommand.setupRegistrationCallback()
}

Functions

Link copied to clipboard
Link copied to clipboard
@Environment(value = EnvType.CLIENT)
@JvmName(name = "setupRegistrationCallbackClient")
fun LiteralArgumentBuilder<ClientCommandSourceStack>.setupRegistrationCallback()

fun LiteralArgumentBuilder<CommandSourceStack>.setupRegistrationCallback()

Set up a callback which automatically registers this command on server startup.

@Environment(value = EnvType.CLIENT)
@JvmName(name = "setupRegistrationCallbackClient")
fun RegistrableCommand<ClientCommandSourceStack>.setupRegistrationCallback()

Register this command (client-side).