From 8f96413d2be41112d22f4c92c167ace72ee98474 Mon Sep 17 00:00:00 2001 From: u9g Date: Sat, 12 Sep 2026 17:19:15 -0400 Subject: [PATCH] Revert the 1.21.6 enum mappers whose ordinals never moved `difficulty.difficulty`, `set_difficulty.newDifficulty`, `game_state_change.reason` and `map_chunk.heightmaps[].type` became mappers in 1.21.6 while staying plain numbers in every earlier protocol. The wire values behind them have not changed in any version, so the mapper buys no stability and only costs compatibility: - Reading, `difficulty` now yields a string, so mineflayer's `difficultyNames[packet.difficulty]` is `undefined` on 1.21.6+ and `bot.game.difficulty` is unset. - Writing, a numeric value throws since ProtoDef-io/node-protodef#176 made the compiled mapper reject values not in the mappings (before that it fell through to the raw value, which is why these went unnoticed). That breaks flying-squid's `game_state_change {reason: 2}` and any client writing `set_difficulty {newDifficulty: 0..3}`. Reverted to the exact pre-1.21.6 types, so existing code needs no change. `difficulty`/`newDifficulty` go back to `u8`: vanilla writes the enum ordinal, and for a 4-value enum that is byte-identical to the varint they were given here. `entity_action.actionId` deliberately keeps its mapper: the two sneak actions moved to `player_input` in 1.21.6, so every ordinal after them shifted by 2 and a numeric value really does mean different things per version. `teams.mode`, `update_structure_block.flags` and `client_command.actionId` (#1284) are left for separate changes. --- data/pc/1.21.11/proto.yml | 37 +++----------------- data/pc/1.21.11/protocol.json | 64 +++-------------------------------- data/pc/1.21.6/proto.yml | 37 +++----------------- data/pc/1.21.6/protocol.json | 64 +++-------------------------------- data/pc/1.21.8/proto.yml | 37 +++----------------- data/pc/1.21.8/protocol.json | 64 +++-------------------------------- data/pc/1.21.9/proto.yml | 37 +++----------------- data/pc/1.21.9/protocol.json | 64 +++-------------------------------- data/pc/26.1/protocol.json | 64 +++-------------------------------- data/pc/latest/proto.yml | 37 +++----------------- 10 files changed, 45 insertions(+), 460 deletions(-) diff --git a/data/pc/1.21.11/proto.yml b/data/pc/1.21.11/proto.yml index 6fbb0a329..06c10b2a0 100644 --- a/data/pc/1.21.11/proto.yml +++ b/data/pc/1.21.11/proto.yml @@ -2055,11 +2055,7 @@ default: void # MC: ClientboundChangeDifficultyPacket packet_difficulty: - difficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + difficulty: u8 difficultyLocked: bool # MC: ClientboundChunkBatchFinishedPacket packet_chunk_batch_finished: @@ -2221,21 +2217,8 @@ chunkX: i32 # MC: ClientboundGameEventPacket packet_game_state_change: - reason: u8 => - 0: no_respawn_block_available - 1: start_raining - 2: stop_raining - 3: change_game_mode - 4: win_game - 5: demo_event - 6: play_arrow_hit_sound - 7: rain_level_change - 8: thunder_level_change - 9: puffer_fish_sting - 10: guardian_elder_effect - 11: immediate_respawn - 12: limited_crafting - 13: level_chunks_load_start + #TODO: Should be a mapper + reason: u8 gameMode: f32 # MC: ClientboundGameTestHighlightPosPacket packet_game_test_highlight_pos: @@ -2268,13 +2251,7 @@ x: i32 z: i32 heightmaps: []varint - type: varint => - 0: world_surface_wg - 1: world_surface - 2: ocean_floor_wg - 3: ocean_floor - 4: motion_blocking - 5: motion_blocking_no_leaves + type: varint data: i64[]varint chunkData: ByteArray blockEntities: chunkBlockEntity[]varint @@ -3340,11 +3317,7 @@ selectedItemIndex: varint # MC: ServerboundChangeDifficultyPacket packet_set_difficulty: - newDifficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + newDifficulty: u8 # MC: ServerboundChangeGameModePacket packet_change_gamemode: mode: varint => diff --git a/data/pc/1.21.11/protocol.json b/data/pc/1.21.11/protocol.json index 7e555a648..276f76205 100644 --- a/data/pc/1.21.11/protocol.json +++ b/data/pc/1.21.11/protocol.json @@ -6246,18 +6246,7 @@ [ { "name": "difficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" }, { "name": "difficultyLocked", @@ -6854,28 +6843,7 @@ [ { "name": "reason", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0": "no_respawn_block_available", - "1": "start_raining", - "2": "stop_raining", - "3": "change_game_mode", - "4": "win_game", - "5": "demo_event", - "6": "play_arrow_hit_sound", - "7": "rain_level_change", - "8": "thunder_level_change", - "9": "puffer_fish_sting", - "10": "guardian_elder_effect", - "11": "immediate_respawn", - "12": "limited_crafting", - "13": "level_chunks_load_start" - } - } - ] + "type": "u8" }, { "name": "gameMode", @@ -6994,20 +6962,7 @@ [ { "name": "type", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "world_surface_wg", - "1": "world_surface", - "2": "ocean_floor_wg", - "3": "ocean_floor", - "4": "motion_blocking", - "5": "motion_blocking_no_leaves" - } - } - ] + "type": "varint" }, { "name": "data", @@ -10290,18 +10245,7 @@ [ { "name": "newDifficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" } ] ], diff --git a/data/pc/1.21.6/proto.yml b/data/pc/1.21.6/proto.yml index 50747c23a..fb69609a0 100644 --- a/data/pc/1.21.6/proto.yml +++ b/data/pc/1.21.6/proto.yml @@ -1739,11 +1739,7 @@ default: void # MC: ClientboundChangeDifficultyPacket packet_difficulty: - difficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + difficulty: u8 difficultyLocked: bool # MC: ClientboundChunkBatchFinishedPacket packet_chunk_batch_finished: @@ -1882,21 +1878,8 @@ chunkX: i32 # MC: ClientboundGameEventPacket packet_game_state_change: - reason: u8 => - 0: no_respawn_block_available - 1: start_raining - 2: stop_raining - 3: change_game_mode - 4: win_game - 5: demo_event - 6: play_arrow_hit_sound - 7: rain_level_change - 8: thunder_level_change - 9: puffer_fish_sting - 10: guardian_elder_effect - 11: immediate_respawn - 12: limited_crafting - 13: level_chunks_load_start + #TODO: Should be a mapper + reason: u8 gameMode: f32 # MC: ClientboundHorseScreenOpenPacket packet_open_horse_window: @@ -1925,13 +1908,7 @@ x: i32 z: i32 heightmaps: []varint - type: varint => - 0: world_surface_wg - 1: world_surface - 2: ocean_floor_wg - 3: ocean_floor - 4: motion_blocking - 5: motion_blocking_no_leaves + type: varint data: i64[]varint chunkData: ByteArray blockEntities: chunkBlockEntity[]varint @@ -2988,11 +2965,7 @@ selectedItemIndex: varint # MC: ServerboundChangeDifficultyPacket packet_set_difficulty: - newDifficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + newDifficulty: u8 # MC: ServerboundChangeGameModePacket packet_change_gamemode: mode: varint => diff --git a/data/pc/1.21.6/protocol.json b/data/pc/1.21.6/protocol.json index 8bfa742c0..f3e773233 100644 --- a/data/pc/1.21.6/protocol.json +++ b/data/pc/1.21.6/protocol.json @@ -4923,18 +4923,7 @@ [ { "name": "difficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" }, { "name": "difficultyLocked", @@ -5443,28 +5432,7 @@ [ { "name": "reason", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0": "no_respawn_block_available", - "1": "start_raining", - "2": "stop_raining", - "3": "change_game_mode", - "4": "win_game", - "5": "demo_event", - "6": "play_arrow_hit_sound", - "7": "rain_level_change", - "8": "thunder_level_change", - "9": "puffer_fish_sting", - "10": "guardian_elder_effect", - "11": "immediate_respawn", - "12": "limited_crafting", - "13": "level_chunks_load_start" - } - } - ] + "type": "u8" }, { "name": "gameMode", @@ -5570,20 +5538,7 @@ [ { "name": "type", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "world_surface_wg", - "1": "world_surface", - "2": "ocean_floor_wg", - "3": "ocean_floor", - "4": "motion_blocking", - "5": "motion_blocking_no_leaves" - } - } - ] + "type": "varint" }, { "name": "data", @@ -8860,18 +8815,7 @@ [ { "name": "newDifficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" } ] ], diff --git a/data/pc/1.21.8/proto.yml b/data/pc/1.21.8/proto.yml index 5906f926d..f35f2916e 100644 --- a/data/pc/1.21.8/proto.yml +++ b/data/pc/1.21.8/proto.yml @@ -1739,11 +1739,7 @@ default: void # MC: ClientboundChangeDifficultyPacket packet_difficulty: - difficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + difficulty: u8 difficultyLocked: bool # MC: ClientboundChunkBatchFinishedPacket packet_chunk_batch_finished: @@ -1882,21 +1878,8 @@ chunkX: i32 # MC: ClientboundGameEventPacket packet_game_state_change: - reason: u8 => - 0: no_respawn_block_available - 1: start_raining - 2: stop_raining - 3: change_game_mode - 4: win_game - 5: demo_event - 6: play_arrow_hit_sound - 7: rain_level_change - 8: thunder_level_change - 9: puffer_fish_sting - 10: guardian_elder_effect - 11: immediate_respawn - 12: limited_crafting - 13: level_chunks_load_start + #TODO: Should be a mapper + reason: u8 gameMode: f32 # MC: ClientboundHorseScreenOpenPacket packet_open_horse_window: @@ -1925,13 +1908,7 @@ x: i32 z: i32 heightmaps: []varint - type: varint => - 0: world_surface_wg - 1: world_surface - 2: ocean_floor_wg - 3: ocean_floor - 4: motion_blocking - 5: motion_blocking_no_leaves + type: varint data: i64[]varint chunkData: ByteArray blockEntities: chunkBlockEntity[]varint @@ -2988,11 +2965,7 @@ selectedItemIndex: varint # MC: ServerboundChangeDifficultyPacket packet_set_difficulty: - newDifficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + newDifficulty: u8 # MC: ServerboundChangeGameModePacket packet_change_gamemode: mode: varint => diff --git a/data/pc/1.21.8/protocol.json b/data/pc/1.21.8/protocol.json index 8bfa742c0..f3e773233 100644 --- a/data/pc/1.21.8/protocol.json +++ b/data/pc/1.21.8/protocol.json @@ -4923,18 +4923,7 @@ [ { "name": "difficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" }, { "name": "difficultyLocked", @@ -5443,28 +5432,7 @@ [ { "name": "reason", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0": "no_respawn_block_available", - "1": "start_raining", - "2": "stop_raining", - "3": "change_game_mode", - "4": "win_game", - "5": "demo_event", - "6": "play_arrow_hit_sound", - "7": "rain_level_change", - "8": "thunder_level_change", - "9": "puffer_fish_sting", - "10": "guardian_elder_effect", - "11": "immediate_respawn", - "12": "limited_crafting", - "13": "level_chunks_load_start" - } - } - ] + "type": "u8" }, { "name": "gameMode", @@ -5570,20 +5538,7 @@ [ { "name": "type", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "world_surface_wg", - "1": "world_surface", - "2": "ocean_floor_wg", - "3": "ocean_floor", - "4": "motion_blocking", - "5": "motion_blocking_no_leaves" - } - } - ] + "type": "varint" }, { "name": "data", @@ -8860,18 +8815,7 @@ [ { "name": "newDifficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" } ] ], diff --git a/data/pc/1.21.9/proto.yml b/data/pc/1.21.9/proto.yml index 35841c0c6..481fa3ab6 100644 --- a/data/pc/1.21.9/proto.yml +++ b/data/pc/1.21.9/proto.yml @@ -1977,11 +1977,7 @@ default: void # MC: ClientboundChangeDifficultyPacket packet_difficulty: - difficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + difficulty: u8 difficultyLocked: bool # MC: ClientboundChunkBatchFinishedPacket packet_chunk_batch_finished: @@ -2143,21 +2139,8 @@ chunkX: i32 # MC: ClientboundGameEventPacket packet_game_state_change: - reason: u8 => - 0: no_respawn_block_available - 1: start_raining - 2: stop_raining - 3: change_game_mode - 4: win_game - 5: demo_event - 6: play_arrow_hit_sound - 7: rain_level_change - 8: thunder_level_change - 9: puffer_fish_sting - 10: guardian_elder_effect - 11: immediate_respawn - 12: limited_crafting - 13: level_chunks_load_start + #TODO: Should be a mapper + reason: u8 gameMode: f32 # MC: ClientboundGameTestHighlightPosPacket packet_game_test_highlight_pos: @@ -2190,13 +2173,7 @@ x: i32 z: i32 heightmaps: []varint - type: varint => - 0: world_surface_wg - 1: world_surface - 2: ocean_floor_wg - 3: ocean_floor - 4: motion_blocking - 5: motion_blocking_no_leaves + type: varint data: i64[]varint chunkData: ByteArray blockEntities: chunkBlockEntity[]varint @@ -3262,11 +3239,7 @@ selectedItemIndex: varint # MC: ServerboundChangeDifficultyPacket packet_set_difficulty: - newDifficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + newDifficulty: u8 # MC: ServerboundChangeGameModePacket packet_change_gamemode: mode: varint => diff --git a/data/pc/1.21.9/protocol.json b/data/pc/1.21.9/protocol.json index 427ea5098..fc8b96376 100644 --- a/data/pc/1.21.9/protocol.json +++ b/data/pc/1.21.9/protocol.json @@ -5956,18 +5956,7 @@ [ { "name": "difficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" }, { "name": "difficultyLocked", @@ -6564,28 +6553,7 @@ [ { "name": "reason", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0": "no_respawn_block_available", - "1": "start_raining", - "2": "stop_raining", - "3": "change_game_mode", - "4": "win_game", - "5": "demo_event", - "6": "play_arrow_hit_sound", - "7": "rain_level_change", - "8": "thunder_level_change", - "9": "puffer_fish_sting", - "10": "guardian_elder_effect", - "11": "immediate_respawn", - "12": "limited_crafting", - "13": "level_chunks_load_start" - } - } - ] + "type": "u8" }, { "name": "gameMode", @@ -6704,20 +6672,7 @@ [ { "name": "type", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "world_surface_wg", - "1": "world_surface", - "2": "ocean_floor_wg", - "3": "ocean_floor", - "4": "motion_blocking", - "5": "motion_blocking_no_leaves" - } - } - ] + "type": "varint" }, { "name": "data", @@ -10000,18 +9955,7 @@ [ { "name": "newDifficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" } ] ], diff --git a/data/pc/26.1/protocol.json b/data/pc/26.1/protocol.json index 41b64ae64..88dfc803d 100644 --- a/data/pc/26.1/protocol.json +++ b/data/pc/26.1/protocol.json @@ -6352,18 +6352,7 @@ [ { "name": "difficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" }, { "name": "difficultyLocked", @@ -6960,28 +6949,7 @@ [ { "name": "reason", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0": "no_respawn_block_available", - "1": "start_raining", - "2": "stop_raining", - "3": "change_game_mode", - "4": "win_game", - "5": "demo_event", - "6": "play_arrow_hit_sound", - "7": "rain_level_change", - "8": "thunder_level_change", - "9": "puffer_fish_sting", - "10": "guardian_elder_effect", - "11": "immediate_respawn", - "12": "limited_crafting", - "13": "level_chunks_load_start" - } - } - ] + "type": "u8" }, { "name": "gameMode", @@ -7115,20 +7083,7 @@ [ { "name": "type", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "world_surface_wg", - "1": "world_surface", - "2": "ocean_floor_wg", - "3": "ocean_floor", - "4": "motion_blocking", - "5": "motion_blocking_no_leaves" - } - } - ] + "type": "varint" }, { "name": "data", @@ -10450,18 +10405,7 @@ [ { "name": "newDifficulty", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "peaceful", - "1": "easy", - "2": "normal", - "3": "hard" - } - } - ] + "type": "u8" } ] ], diff --git a/data/pc/latest/proto.yml b/data/pc/latest/proto.yml index e60b8ef51..607dcbbce 100644 --- a/data/pc/latest/proto.yml +++ b/data/pc/latest/proto.yml @@ -2108,11 +2108,7 @@ default: void # MC: ClientboundChangeDifficultyPacket packet_difficulty: - difficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + difficulty: u8 difficultyLocked: bool # MC: ClientboundChunkBatchFinishedPacket packet_chunk_batch_finished: @@ -2274,21 +2270,8 @@ chunkX: i32 # MC: ClientboundGameEventPacket packet_game_state_change: - reason: u8 => - 0: no_respawn_block_available - 1: start_raining - 2: stop_raining - 3: change_game_mode - 4: win_game - 5: demo_event - 6: play_arrow_hit_sound - 7: rain_level_change - 8: thunder_level_change - 9: puffer_fish_sting - 10: guardian_elder_effect - 11: immediate_respawn - 12: limited_crafting - 13: level_chunks_load_start + #TODO: Should be a mapper + reason: u8 gameMode: f32 # MC: ClientboundGameRuleValuesPacket packet_game_rule_values: @@ -2324,13 +2307,7 @@ x: i32 z: i32 heightmaps: []varint - type: varint => - 0: world_surface_wg - 1: world_surface - 2: ocean_floor_wg - 3: ocean_floor - 4: motion_blocking - 5: motion_blocking_no_leaves + type: varint data: i64[]varint chunkData: ByteArray blockEntities: chunkBlockEntity[]varint @@ -3409,11 +3386,7 @@ selectedItemIndex: varint # MC: ServerboundChangeDifficultyPacket packet_set_difficulty: - newDifficulty: varint => - 0: peaceful - 1: easy - 2: normal - 3: hard + newDifficulty: u8 # MC: ServerboundChangeGameModePacket packet_change_gamemode: mode: varint =>