gnembon / fabric-carpet

Fabric Carpet
MIT License
1.65k stars 261 forks source link

`__on_player_command` cannot be canceled #1739

Open shenjackyuanjie opened 1 year ago

shenjackyuanjie commented 1 year ago

the problem

__on_player_command cannot be canceled

how dose the issue cause

At https://github.com/gnembon/fabric-carpet/commit/bf00051482883dd232bc4837418a2cbd3828f963#diff-c0b8d21ffce3a7e67a88bad905379bdccb7d9b64e9be98f4739607b1573b75a0

The __on_player_message event was added At the moment, the event was uncancelable

At https://github.com/gnembon/fabric-carpet/commit/24b9c386ec2a3527ba4e19c0fb2fbae9f522724c#diff-c0b8d21ffce3a7e67a88bad905379bdccb7d9b64e9be98f4739607b1573b75a0R302

Many event have ability to canceled

At https://github.com/gnembon/fabric-carpet/commit/43bb84437fc7c3214523c25b530e36aa3c85c014#diff-c0b8d21ffce3a7e67a88bad905379bdccb7d9b64e9be98f4739607b1573b75a0R313

The __on_player_command event was also added to make on_player_message event not triggered by player command but at the same time https://github.com/gnembon/fabric-carpet/commit/43bb84437fc7c3214523c25b530e36aa3c85c014#diff-8604ab23b322f862f9399fb1e6a685ea4900460b0202453c399f8221c09ba72c the docs was modified, the line 321 was been moved to line 324, with no changes witch tells people "the command event is cancelable, the message event is not"

but the truth is the command event mixin can't cancel https://github.com/gnembon/fabric-carpet/commit/43bb84437fc7c3214523c25b530e36aa3c85c014#diff-c0b8d21ffce3a7e67a88bad905379bdccb7d9b64e9be98f4739607b1573b75a0R313

So now the __on_player_command event can't cancel and the __on_player_message can

how to fix it

add a ci.cancel at https://github.com/gnembon/fabric-carpet/blob/43bb84437fc7c3214523c25b530e36aa3c85c014/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java#L313

change docs for these two event

shenjackyuanjie commented 1 year ago

I'm making a PR for it(