Fabric API

Fabric API

106M Downloads

Inline commands from client command chat output are executed server-side only, rather than client-side first

James103 opened this issue ยท 4 comments

commented

When a client command is executed and produces output that contains inline commands, such as the coordinates in /cfind @e, the inline commands are executed server-side only rather than client-side first.

This means client commands do not work when executed from clicking on a chat message; they only work when executed directly.

To reproduce:

  1. Create a new instance with Fabric Loader 0.14.7 and Minecraft 1.19.
  2. Install Fabric API 0.58.0.
  3. Install Client Commands 2.7.
  4. Start the instance.
  5. Create a new world with cheats enabled.
  6. Run /cfind @e
  7. Click on one of the sets of coordinates in the output of the above command.
  8. clook block <x> <y> <z> fails to execute on the server side due to "Unknown or incomplete command"
  9. Open chat, type /clook block 123 456 789, then press enter.
  10. The command executes successfully, adjusting your rotation.

This is likely because 1.19 separated commands and chat messages into their own, breaking setups like this in the process.

Moved from Earthcomputer/clientcommands#438

commented

As a result, I don't see how this issue could occur in Minecraft 1.19 short of mod conflicts

The mod "dotone" (https://github.com/apple502j/dotone) also causes this issue as it backports some 1.19.1 changes to 1.19.0.

Most notably, the following mixin is what's causing this issue: https://github.com/apple502j/dotone/blob/1.19/src/main/java/io/github/apple502j/dotone/mixin/client/ClientPlayerEntityMixin.java

Edit: As per the linked issue below, the author of that mod is not willing to fix this issue on their side. Therefore, this must be fixed on Fabric API side.

commented

In Minecraft 1.19, a click event that runs a command calls sendCommand(String, Text) with the unprefixed command. This case is already covered by the ClientPlayerEntityMixin class:

@Inject(method = "sendCommand(Ljava/lang/String;Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true)
private void onSendCommand(String command, Text preview, CallbackInfo info) {
if (ClientCommandInternals.executeCommand(command)) {
info.cancel();
}
}

As a result, I don't see how this issue could occur in Minecraft 1.19 short of mod conflicts. If this issue meant to refer to Minecraft 1.19.1, I believe I have found the cause of the issue.

In the Minecraft 1.19.1 pre-releases, the sendCommand(String) method is called instead in this same case so that the click event command is not signed. Since the mixin only targets the signed sendCommand(String, Text) overload, which uses a different code path than sendCommand(String), the client command dispatcher never attempts to execute the command.

In short, this issue in theory is caused by the ClientPlayerEntityMixin class only handling sendCommand(String, Text) and not sendCommand(String).

commented

I can confirm that this issue occurs in Minecraft 1.19.1 with only Fabric API and a mod that adds client commands.

commented

Fixed, new version going out now.