Class ClientCommandHandler

java.lang.Object
net.neoforged.neoforge.client.ClientCommandHandler

public class ClientCommandHandler extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack>
     
    private static final org.apache.logging.log4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static <S> void
    copy(com.mojang.brigadier.tree.CommandNode<S> sourceNode, com.mojang.brigadier.tree.CommandNode<S> resultNode)
    Creates a deep copy of the sourceNode while keeping the redirects referring to the old command tree
    static com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack>
     
     
    private static void
     
    static void
     
    static com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.SharedSuggestionProvider>
    mergeServerCommands(com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.SharedSuggestionProvider> serverCommands, net.minecraft.commands.CommandBuildContext buildContext)
     
    static boolean
    runCommand(String command)
    Always try to execute the cached parsing of a typed command as a clientside command.

    Methods inherited from class java.lang.Object

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

    • LOGGER

      private static final org.apache.logging.log4j.Logger LOGGER
    • commands

      private static com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> commands
  • Constructor Details

    • ClientCommandHandler

      public ClientCommandHandler()
  • Method Details

    • init

      public static void init()
    • handleClientPlayerLogin

      private static void handleClientPlayerLogin(ClientPlayerNetworkEvent.LoggingIn event)
    • mergeServerCommands

      @Internal public static com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.SharedSuggestionProvider> mergeServerCommands(com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.SharedSuggestionProvider> serverCommands, net.minecraft.commands.CommandBuildContext buildContext)
    • getDispatcher

      public static com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> getDispatcher()
      Returns:
      The command dispatcher for client side commands
    • getSource

      public static ClientCommandSourceStack getSource()
      Returns:
      A ClientCommandSourceStack for the player in the current client
    • copy

      private static <S> void copy(com.mojang.brigadier.tree.CommandNode<S> sourceNode, com.mojang.brigadier.tree.CommandNode<S> resultNode)
      Creates a deep copy of the sourceNode while keeping the redirects referring to the old command tree
      Parameters:
      sourceNode - the original
      resultNode - the result
    • runCommand

      public static boolean runCommand(String command)
      Always try to execute the cached parsing of a typed command as a clientside command. Requires that the execute field of the commands to be set to send to server so that they aren't treated as client command's that do nothing. Commands.performCommand(ParseResults, String) for reference
      Parameters:
      command - the full command to execute, no preceding slash
      Returns:
      false leaves the message to be sent to the server, while true means it should be caught before LocalPlayer#sendCommand