Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client: Don't allow dropping items while dead #15737

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

appgurueu
Copy link
Contributor

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.

@appgurueu appgurueu added Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines Bugfix 🐛 PRs that fix a bug labels Jan 30, 2025
if (wasKeyDown(KeyType::DROP)) {
const auto *player = client->getEnv().getLocalPlayer();
const bool dead = player->getCAO() && player->isDead();
if (wasKeyDown(KeyType::DROP) && !dead) {
dropSelectedItem(isKeyDown(KeyType::SNEAK));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it make more sense to put this check in dropSelectedItem

@Zughy
Copy link
Contributor

Zughy commented Jan 31, 2025

but that should be relatively unlikely to happen

I can confirm that it happens, although rarely (still annoying)

Ideally we would also want to disable other controls

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 PRs that fix a bug Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Items "disappear" if dropped when dead (and reappear when an inventory action is performed)
3 participants