Skip to content

fix: send player loaded before spawn on 1.21.4+ - #3960

Open
aibengineering wants to merge 2 commits into
PrismarineJS:masterfrom
aibengineering:fix/player-loaded-before-actions
Open

fix: send player loaded before spawn on 1.21.4+#3960
aibengineering wants to merge 2 commits into
PrismarineJS:masterfrom
aibengineering:fix/player-loaded-before-actions

Conversation

@aibengineering

@aibengineering aibengineering commented Aug 12, 2026

Copy link
Copy Markdown

Summary

Since Java 1.21.4, vanilla defers initial block and item interactions until it receives player_loaded or its fallback expires. Mojang documents the packet after the initial loading-terrain screen and again after respawn in the 1.21.4 release notes.

Mineflayer emits spawn without sending the packet, so actions started immediately from a spawn listener can be silently ignored. This sends player_loaded immediately before spawn, including after respawn.

The behavior is gated with bot.supportFeature('sendsPlayerLoadedPacket'), defined by the corresponding minecraft-data PR #1224. This PR therefore depends on that feature being merged and released through node-minecraft-data.

Reproduction

Run the existing 1.21.4 crafting test by itself on current Mineflayer master:

npm run mocha_test -- test/externalTest.js \
  --grep '^mineflayer_external 1\.21\.4v crafting$' \
  --retries 0

Before:

0 passing
1 failing
Error: Event windowOpen did not fire within timeout of 20000ms

After:

1 passing

Related work

This overlaps with the 26.2 work in #3926. PR #3958 independently identified the same missing packet among broader 26.x changes; this PR isolates the lifecycle fix and applies it to every version described by the minecraft-data feature flag.

Sending player_loaded before spawn preserves Mineflayer's contract that spawn listeners may begin interacting with the server.

Verification

Java Edition 1.21.4 added the serverbound player_loaded packet. Send it before Mineflayer's spawn event on initial load and respawn so callers cannot interact while vanilla still ignores player actions.

Reproduce on unmodified upstream:

npm run mocha_test -- test/externalTest.js --grep '^mineflayer_external 1\.21\.4v crafting$' --retries 0

The full-title grep limits Mocha to that one version and test even though externalTest.js declares every supported version. Upstream fails after 20 seconds waiting for windowOpen; this change passes the same single test.
@aibengineering aibengineering changed the title fix: signal player loaded before spawn fix: send player loaded before spawn on 1.21.4+ Aug 12, 2026
u9g added a commit that referenced this pull request Aug 23, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
@u9g u9g changed the title fix: send player loaded before spawn on 1.21.4+ x Aug 23, 2026
@u9g u9g changed the title x fix: send player loaded before spawn on 1.21.4+ Aug 23, 2026
u9g added a commit that referenced this pull request Aug 27, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
u9g added a commit that referenced this pull request Aug 27, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
u9g added a commit that referenced this pull request Aug 27, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
u9g added a commit that referenced this pull request Aug 27, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
u9g added a commit that referenced this pull request Aug 27, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
u9g added a commit that referenced this pull request Aug 29, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
u9g added a commit that referenced this pull request Aug 31, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
u9g added a commit that referenced this pull request Sep 4, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
u9g added a commit that referenced this pull request Sep 4, 2026
The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).
rom1504 pushed a commit that referenced this pull request Sep 5, 2026
* Speed up furnace external test by fast-forwarding CookTime

The furnace test spent ~10s per version waiting out a real 200-tick
smelt. Instead, after asserting the smelt has genuinely started
(0 < progress < 1), merge CookTime:195s into the furnace block entity
and wait for the output slot to populate — the output is still produced
by the vanilla tick path, so all assertions are unchanged. Cuts the
test from ~12s to ~3s per version, ~4.5 minutes across the matrix.

The await runs 250-320ms on every tested version, so it uses a tight
500ms timeout: if the merge silently does nothing (wrong field name or
command for a future version), the test fails fast instead of sitting
out the real smelt.

Verified against real servers on all 28 tested versions (1.21.4+
placement verified on top of PR #3960, which master needs for those
versions regardless of this change).

* test(furnace): gate the NBT fast-forward on minecraft-data features

Replaces the hardcoded version comparisons with hasDataCommand and
furnaceNbtUsesSnakeCase (PrismarineJS/minecraft-data#1260).
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