Skip to content

fix: preserve item use across unrelated entity status notifications - #4053

Open
aibengineering wants to merge 3 commits into
PrismarineJS:masterfrom
aibengineering:fix/item-use-entity-status
Open

fix: preserve item use across unrelated entity status notifications#4053
aibengineering wants to merge 3 commits into
PrismarineJS:masterfrom
aibengineering:fix/item-use-entity-status

Conversation

@aibengineering

@aibengineering aibengineering commented Sep 5, 2026

Copy link
Copy Markdown

An entity_status notification does not necessarily end the bot's active item use. A nearby mob's hurt status currently clears bot.usingHeldItem; after filtering foreign entities, the bot's own hurt and successful shield-block statuses still clear it. That can make callers believe a bow draw or shield use has already ended.

This change checks both facts in the inventory handler:

  • Ignore notifications for other entities.
  • For the bot itself, preserve item use unless the status is consumption completion (9) or death (3).

Consumption completion still finishes the pending consume() task. Explicit item deactivation remains effective. A successful shield block or hurt notification preserves the active-use flag.

The real inventory-plugin regression runs in every supported CI version group. It covers foreign hurt/death/completion/shield-block notifications, own hurt/shield-block notifications, own death, and a successful consumption completion. The own hurt and shield-block cases both fail against the previous PR head on 1.21.4 and pass with this follow-up.

Validation:

  • bun node_modules/mocha/bin/mocha.js test/inventoryItemUseTest.js test/diggingDeathTest.js --exit: 228 passing, including 224 inventory cases across 28 supported versions.
  • JavaScript Standard Style on both changed files: passed.
  • node node_modules/mocha/bin/mocha.js test/internalTest.js --grep '1.8.8v|1.21.4v' --exit: 54 passing, 4 version-dependent skips.
  • A separate Minecraft 1.21.4 physical qualification of this same handler repair in our combined fork observed a real arrow blocked at full health, with item use remaining active until explicit release.
  • The broader local internal suite under Bun finished with 709 passing, 53 pending, 8 failing. Failures involved rain-state assertions, world-respawn timeouts, and their cleanup hooks; the isolated baseline 1.8.8 rerun passed, so those broader-run failures are not attributed to a confirmed cause. The full external Minecraft server/version matrix has not been rerun locally for this follow-up; upstream CI supplies that check.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Tests more than 1.5x slower than master (durations are noisy, so this is informational):

   1862ms ->    7470ms  mineflayer_external 1.17.1v activateItem

@aibengineering
aibengineering force-pushed the fix/item-use-entity-status branch from 58b3dcf to cbdee5f Compare September 5, 2026 09:44
@aibengineering aibengineering changed the title fix: ignore foreign entity status when tracking item use fix: preserve item use across unrelated entity status notifications Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant