fix: send player loaded before spawn on 1.21.4+ - #3960
Open
aibengineering wants to merge 2 commits into
Open
Conversation
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.
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
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Since Java 1.21.4, vanilla defers initial block and item interactions until it receives
player_loadedor 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
spawnwithout sending the packet, so actions started immediately from aspawnlistener can be silently ignored. This sendsplayer_loadedimmediately beforespawn, 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 throughnode-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 0Before:
After:
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_loadedbeforespawnpreserves Mineflayer's contract thatspawnlisteners may begin interacting with the server.Verification
npm run lint