CottonMC / ClientCommands

A Minecraft mod that adds support for client-side commands.
MIT License
21 stars 7 forks source link

Tab complete does not honor requires() #16

Open unascribed opened 3 years ago

unascribed commented 3 years ago

Registering a client command that has a requires() check does not remove it from tab complete like it does on the server.

Accepting the completion shows an immediate syntax error and highlights the command in red, so the requirement is recognized, but the tab complete isn't honoring it.

Minecraft 1.16.3, Fabric Loader v0.10.0+build.208, Fabric API 0.22.0+build.408-1.16

Workaround: Just don't register the command. Works in my case as my requires() check was "integrated server is absent", but more complex checks don't have that luxury.

i509VCB commented 3 years ago

So this is the result of a fundamental difference between commands originating on the server and client act. A command registered on the server will go through the requires check and will be omitted from the command tree the client receives if a player cannot access the command.

Likewise the command dispatcher on the client has no filtering of these "inaccessible" nodes, so some internal logic changes would be required to handle that.

unascribed commented 3 years ago

I see; still getting used to Brigadier.

If this is complicated to implement it's probably not worth bothering. Just noticed the discrepancy between server and client command behavior.

i509VCB commented 3 years ago

Juuz has been working on integrating this into fabric api, so fixing this is going to be essential.

Juuxel commented 3 years ago

I did this for the Fabric API PR (FabricMC/fabric#1115), but it'd need quite a lot of modification to fit CCC so I'm not most likely going to port them here. (If it doesn't get merged, I'll probably reuse the FabLabs API as a new major version of CCC.)