Class RegisterClientCommandsEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.client.event.RegisterClientCommandsEvent

public class RegisterClientCommandsEvent extends net.neoforged.bus.api.Event
Fired to allow mods to register client commands.

Some command arguments behave differently for the client commands dispatcher:

  • invalid reference
    ResourceLocationArgument#getAdvancement(com.mojang.brigadier.context.CommandContext, String)
    only returns advancements that are shown on the advancements screen.
  • ObjectiveArgument.getObjective(com.mojang.brigadier.context.CommandContext, String) only returns objectives that are displayed to the player.

This event is not

invalid reference
cancellable
, and does not
invalid reference
have a result
.

This event is fired on the main Forge event bus, only on the logical client.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final net.minecraft.commands.CommandBuildContext
     
    private final com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RegisterClientCommandsEvent(com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> dispatcher, net.minecraft.commands.CommandBuildContext context)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.commands.CommandBuildContext
    Returns the context to build the commands for.
    com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack>
    Returns the command dispatcher for registering commands to be executed on the client.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dispatcher

      private final com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> dispatcher
    • context

      private final net.minecraft.commands.CommandBuildContext context
  • Constructor Details

    • RegisterClientCommandsEvent

      @Internal public RegisterClientCommandsEvent(com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> dispatcher, net.minecraft.commands.CommandBuildContext context)
  • Method Details

    • getDispatcher

      public com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> getDispatcher()
      Returns the command dispatcher for registering commands to be executed on the client.
      Returns:
      the command dispatcher for registering commands to be executed on the client
    • getBuildContext

      public net.minecraft.commands.CommandBuildContext getBuildContext()
      Returns the context to build the commands for.
      Returns:
      the context to build the commands for