Write protocol enum fields by name where the version maps them - #4079
Closed
u9g wants to merge 1 commit into
Closed
Conversation
26.1 describes use_entity.hand and client_command.actionId as mappers, and 1.21.6+ does the same for entity_action.actionId. protodef writes a mapper by name and throws on anything else, so activateEntity, respawn and wake sent nothing at all on those versions. game.js also wrote the respawn command with an `action` field, which no version has. enumField takes the index the protocol documents and returns the name when the version's schema maps the field.
Contributor
|
Tests more than 1.5x slower than master (durations are noisy, so this is informational): |
Member
Author
extremeheat
reviewed
Sep 7, 2026
extremeheat
left a comment
Member
There was a problem hiding this comment.
The more correct thing to do is fix the data by making it consistent upstream. Alot of the features for this kind of thing are code smells
Member
|
Could be worthwhile to make a script that verifies that between all the versions that an identically named field doesn't switch between integer and mapper type. That would make it easier to fix. Could be added to a protocol test too to catch this kind of thing |
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.
bot.activateEntity,bot.respawnandbot.wakesend nothing on the versions whose schema describes the field as a mapper.use_entity.hand(main_hand/off_hand) andclient_command.actionId(perform_respawn/request_stats/request_gamerule_values).entity_action.actionId, whichbed.jswrites as2.game.jswrote the post-win_gamerespawn as{ action: 0 }; no version has anactionfield on that packet.protodef's compiled mapper writes the name and throws on anything else (ProtoDef-io/node-protodef#176), so each of these raises
SizeOf error ... is not in the mappings valueon the serializer stream and the packet never reaches the server. Before that change the numeric form happened to serialize to the same bytes, so nothing on the wire changes here.enumField(registry, packet, field, index)returns the mapped name when the version's schema maps the field and the index otherwise.Two regression tests in
test/internalTest.jsdriveactivateEntityandrespawnagainst the mock server, which parses what the bot writes, so a value the serializer rejects fails the test. Also checked against a live 26.1 server (JartexNetwork, ViaVersion): right-clicking an NPC raised the serializer error and did nothing before the change, and completes the interaction after it.