Fix double-applied +1 offset in sound IDs (SoundsDataGenerator)#76
Open
arielvino wants to merge 1 commit into
Open
Fix double-applied +1 offset in sound IDs (SoundsDataGenerator)#76arielvino wants to merge 1 commit into
arielvino wants to merge 1 commit into
Conversation
SoundsDataGenerator added +1 to every sound's registry id for 1.19.2+, with a comment reasoning that "Mojang uses 0 in the packet to say read a string id instead." That is true of the *wire encoding*: the sound_effect packet writes the sound as an IdOr<SoundEvent> = VarInt(rawId + 1), where 0 signals an inline SoundEvent. But that offset belongs to the packet codec, not the registry dump. prismarine-protocol's registryEntryHolder already does `n - 1` when decoding, so baking +1 into sounds.json double-counts and shifts every consumer's sound lookup by one (e.g. entity.player.hurt resolves as entity.player.death). Emit the raw 0-indexed registry id instead. Verified against a vanilla 1.21.11 server's own --reports registry dump: raw ids match server[N] exactly. Affects 1.19.2, 1.20, 1.21, 1.21.3, 1.21.5, 1.21.6, 1.21.7, 1.21.8, 1.21.9, 1.21.10, 1.21.11. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
arielvino
marked this pull request as ready for review
July 13, 2026 14:00
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.
Problem
SoundsDataGeneratoremitsregistry.getId(sound) + 1for 1.19.2+, with a comment:That protocol fact is real, but the offset is in the wrong layer. On the wire the
sound_effectpacket encodes the sound as anIdOr<SoundEvent>=VarInt(rawId + 1), where0signals an inlineSoundEvent. That+1belongs to the packet codec, not the registry dump.Consumers already handle the wire offset. In
minecraft-protocol, theregistryEntryHoldertype decodes it:So baking +1 into sounds.json double-counts: the codec subtracts 1 to get the raw id, then the lookup hits a table shifted +1 — every sound resolves to the next entry in registry order. In practice entity.player.hurt reads as entity.player.death, entity.player.small_fall as entity.player.levelup, etc., surfacing to downstream users (mineflayer) as phantom events.
Fix
Emit the raw 0-indexed registry id (drop the + 1) across all affected versions: 1.19.2, 1.20, 1.21, 1.21.3, 1.21.5, 1.21.6, 1.21.7, 1.21.8, 1.21.9, 1.21.10, 1.21.11. Versions ≤1.18, 1.19 and 1.20.4 were already correct.
Verification
This change makes the generator emit exactly
registry.getId(sound)- the rawsound_eventregistry id. I validated that value against the game's own authoritative registry: for each affected version I ran the vanilla server's built-in report generator (java -jar server.jar --reports), which dumpsminecraft:sound_eventwith each entry'sprotocol_id, and compared it id-for-id against the corresponding 0-indexedsounds.json:11 versions, 17,944 sound ids, 0 mismatches —
1.19.2, 1.20.1, 1.20.2, 1.21.1, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.8, 1.21.9, 1.21.11.The name-set of each file was also cross-checked against the vanilla registry via misode/mcmeta.