Skip to content

Fix BlockPredicate decoding on 1.21.5+ servers - #391

Open
vaperion wants to merge 1 commit into
azalea-rs:mainfrom
vaperion:fix/block-predicate-decoding
Open

vaperion wants to merge 1 commit into
azalea-rs:mainfrom
vaperion:fix/block-predicate-decoding

Conversation

@vaperion

Copy link
Copy Markdown

Azalea dropped any container packet that contained an item with can_break or can_place_on because the BlockPredicate codec was not updated to match the vanilla changes in 1.21.5.

BlockStateValueMatcher was being read as a varint, but vanilla now sends it as an Either using a bool (true for exact, false for range). This caused exact matchers to be read as ranges, so the value string's length ended up being read as the "has min" bool, breaking everything after it.

BlockPredicate was also missing the component matchers added in 1.21.5 after the nbt field (exact components and partial predicates). Partial predicates use fromCodecWithRegistries, so the value is just an NBT tag.

Since the whole packet failed to read, any GUI would also show up empty if the player had one of these items in their inventory, because ContainerSetContent includes the player's inventory slots.

Seen with a hoe that has can_break for wheat/carrots/potatoes at age=7:

Error reading packet container_set_content (id 18): Invalid UTF-8: [0, 0, 0, 1, 2, 207, 1, 1, 1, 3, 97, 103, 101, 1, 1, 55, ...]

This branch has not been deployed

No deployments
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