Skip to content

Conversation

@micahstubbs
Copy link

@micahstubbs micahstubbs commented Dec 7, 2025

Summary

First, thank you to the PrismarineJS maintainers for this incredible project. The mineflayer/minecraft-protocol ecosystem has been invaluable for our work on AI-powered Minecraft bots.

Problem

When connecting a mineflayer bot to a 1.21.10 server, we encountered PartialReadError: Read error for undefined : undefined errors when parsing spawn_entity and entity_velocity packets. The errors occurred at the i16 reader for velocity fields.

Root Cause Investigation

We captured raw packet bytes and manually parsed them:

spawn_entity packet captured:
Total length: 50 bytes
After parsing entityId, UUID, type, x/y/z, pitch/yaw/headPitch, objectData:
  - Bytes consumed: 49
  - Remaining: 1 byte
  - Expected for velocity: 6 bytes (3x i16)

The packets are ~5 bytes shorter than expected, indicating the velocity fields (velocityX, velocityY, velocityZ) are no longer included in 1.21.10.

Changes

  1. spawn_entity: Removed velocity fields, added restBuffer to handle remaining data
  2. entity_velocity: Same treatment for consistency

Testing

  • Tested with actual 1.21.10 server (protocol 773)
  • Bot now connects, spawns, and operates without parse errors
  • Used raw packet captures to verify the fix matches actual wire format

Note

We noticed PR #1118 has keep_alive at 0x2a, while our testing showed 0x2b works correctly. This might warrant further investigation, but we wanted to keep this PR focused on the structure fixes. Happy to help debug the packet ID mapping further if needed.

Related

Building on PR PrismarineJS#1118's packet ID mapping fixes, this commit addresses
additional packet structure issues discovered during testing:

1. spawn_entity: Remove velocity fields (velocityX/Y/Z)
   - Server packets are ~5 bytes shorter than expected
   - Velocity fields appear to be removed or sent differently in 1.21.10
   - Use restBuffer to handle any remaining data gracefully

2. entity_velocity: Same treatment for consistency
   - The i16 velocity fields cause parse errors
   - Replace with restBuffer to avoid PartialReadError

These fixes were discovered while debugging mineflayer/mindcraft bot
connectivity to a 1.21.10 server. Raw packet captures confirmed the
shorter packet sizes.

References:
- PR PrismarineJS#1118: Packet ID mapping fixes
- Tested with actual 1.21.10 server (protocol 773)
…elocity fixes

- Created proto.yml for 1.21.10 based on 1.21.8
- Removed velocity fields from packet_spawn_entity (not sent in 1.21.10)
- Updated packet_entity_velocity to use restBuffer (format changed in 1.21.10)
- Updated dataPaths.json to point proto to pc/1.21.10
- Regenerated protocol.json using npm run build in tools/js

This follows the proper YAML-based contribution workflow.
@micahstubbs
Copy link
Author

micahstubbs commented Dec 7, 2025

Thanks for the feedback @rom1504. I've updated this PR to follow the proper workflow:

  1. Created proto.yml for 1.21.10 based on 1.21.8
  2. Made the packet structure fixes in the YAML:
    • Removed velocity fields from packet_spawn_entity (not sent in protocol 773)
    • Updated packet_entity_velocity to use restBuffer (format changed)
  3. Updated dataPaths.json to point proto to pc/1.21.10
  4. Regenerated protocol.json using npm run build in tools/js

The changes are now properly based on YAML source. Let me know if there's anything else that needs adjustment.

@micahstubbs micahstubbs marked this pull request as ready for review December 7, 2025 12:45
@micahstubbs micahstubbs marked this pull request as draft December 7, 2025 12:48
- Added 5 placeholder packets (0x26-0x2a) to shift keep_alive to 0x2b and login to 0x30
- This matches the actual 1.21.10 protocol behavior observed in testing
- Bot now works without runtime fix scripts
@micahstubbs
Copy link
Author

Added packet ID mapping fixes:

  • Added 5 placeholder packets (0x26-0x2a) to shift keep_alive to 0x2b and login to 0x30
  • This matches the actual 1.21.10 protocol (773) behavior observed in testing
  • Bot now connects and works without any runtime protocol fix scripts

Tested successfully with a mineflayer bot connecting to a Minecraft 1.21.10 server.

@chiterl
Copy link

chiterl commented Dec 7, 2025

is it able to open guis without crashing

@richnetdesign
Copy link

I believe 1.21.10 is just a minor hot fix release. The major protocol changes happened in 1.21.9

I am trying to fix here
#1120

@micahstubbs
Copy link
Author

@chiterl, yes but still has warnings. trying to fix those warnings before marking this as ready for review.

@richnetdesign oh! will check your PR. thanks for pointing that out.

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.

3 participants