Skip to content

bed: wake() sends the right entity_action on 1.21.11+ (leave_bed renumbered; 2 is stop_sprinting there) - #4047

Open
cleverark wants to merge 1 commit into
PrismarineJS:masterfrom
cleverark:fix/wake-leave-bed-1.21.11
Open

bed: wake() sends the right entity_action on 1.21.11+ (leave_bed renumbered; 2 is stop_sprinting there)#4047
cleverark wants to merge 1 commit into
PrismarineJS:masterfrom
cleverark:fix/wake-leave-bed-1.21.11

Conversation

@cleverark

Copy link
Copy Markdown

Problem

On 1.21.11 and later, bot.wake() does nothing: the bot stays in bed until the server wakes it.

1.21.11 moved start/stop sneaking out of entity_action (they went to player_input), so the remaining actions renumbered and the field became a named mapping. leave_bed is 0 there; it was 2 before. wake() still sends 2, which those servers read as stop_sprinting.

Seen live on a Paper 26.1.2 server with a second player online: bot.sleep() worked (advancement "Sweet Dreams" logged), bot.wake() resolved, bot.isSleeping stayed true, and the bot lay there until it was disconnected.

Fix

Read the protocol definition once at inject time: when actionId is a mapper, send 'leave_bed' by name; otherwise send the bare 2 as before. No version table to maintain, and older servers are unchanged.

Why the external test didn't catch it

test/externalTests/bed.js sleeps and then awaits wake. On the test server the bot is the only player, so ~100 ticks after it lies down the night is skipped and the server wakes it, whether or not wake() worked. The test now checks that the clock is still night after wake() resolves — a real wake leaves the clock alone, a night skip resets it to morning.

Notes

  • Verified against minecraft-data: entity_action.actionId is a bare varint on 1.8–1.21.10 and a mapper (0: leave_bed, 1: start_sprinting, 2: stop_sprinting, …) on 1.21.11 and 26.1.
  • If you'd rather gate this on a features.json flag in minecraft-data than on the protocol shape, happy to change it — the protocol read seemed the least surprising since it's the packet itself that changed.

🤖 Generated with Claude Code

…fted; 2 is stop_sprinting there)

1.21.11 moved start/stop sneaking out of entity_action, so the remaining
actions renumbered and the field became a named mapping: leave_bed is 0,
where it used to be 2. wake() still sent 2, which those servers read as
stop_sprinting — the bot slept on until the server itself woke it. Read the
protocol definition and send the name when it's mapped, the number otherwise.

The bed external test didn't catch this because a lone sleeper on the test
server skips the night, and the server wakes the bot at dawn. It now checks
the clock is still night after wake() resolves.

Found on a Paper 26.1.2 server where another player was online (so no night
skip): bot.sleep() worked, bot.wake() resolved, bot.isSleeping stayed true.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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