Client: Don't allow dropping items while dead#15737
Client: Don't allow dropping items while dead#15737appgurueu wants to merge 1 commit intoluanti-org:masterfrom
Conversation
| const auto *player = client->getEnv().getLocalPlayer(); | ||
| const bool dead = player->getCAO() && player->isDead(); | ||
| if (wasKeyDown(KeyType::DROP) && !dead) { | ||
| dropSelectedItem(isKeyDown(KeyType::SNEAK)); |
There was a problem hiding this comment.
wouldn't it make more sense to put this check in dropSelectedItem
I can confirm that it happens, although rarely (still annoying)
We should get rid of the death concept and let mods implement it. AUX doesn't work, drop key won't work after this PR, but there are controls that current games (i.e. mine) use whilst dead, like hotbar actions. Changing it will break my game. WASD currently works (so I need to anchor dead players to an invisible entity) but there might be games that would like to exploit such behaviour (e.g. for a ghost state. But that will likely introduce more issues) |
|
I still think we should have this for proper clientside prediction, though that is lower priority. Otherwise the item disappears for a moment on the client until the server corrects the prediction, when the client already knows itself that it can't drop items while dead. I can also fix some more clientside behavior when dead (for example: the world still being pointable, despite you being unable to interact with anything) to "sweeten the pot". |
Should fix #15728 in ~95%? of cases, effectively going back to the previous state (where the formspec prevented this), and should be something we definitely want to do, no matter whether we fix it fully in the future.
There might technically still be a possible race condition if items are dropped in the very moment the player dies, but that should be relatively unlikely to happen.
Ideally we would also want to disable other controls, but as it turns out that requires different changes in different places and I don't want to pollute this trivial PR.
How to test
As described in the issue. Observe that you simply can't drop things while dead anymore.