fix(protocol): remap item/block state IDs and entity metadata for older Java clients (#2185)

* fix(protocol): remap item/block state IDs and entity metadata for older Java clients

The server was using reversed ViaVersion mappings (designed for old→new)
to downgrade packets for older clients, which produced ID collisions and
incorrect fallbacks for 26.1-exclusive items and block states.

Changes:
- Replace ViaVersion with ViaBackwards mapping files for item ID and
  block state remapping, which provide the correct new→old direction
  with proper closest-item fallbacks for 26.1-exclusive content
- Fix CSetEntityMetadata to remap ItemStack item IDs per client version,
  matching the version-aware handling already done for inventory packets
  and block state metadata
- Fix TrackedData codegen to resolve Java JSON keys correctly by trying
  both bare names and DATA_-prefixed names, and iterate the union of all
  version keys instead of only the latest (Bedrock) version
- Fix LootCondition::MatchTool to default to false instead of true,
  preventing silk-touch loot table branches from always winning and
  causing ores to drop themselves instead of their correct items

Fixes: block drops invisible on older Java clients
Fixes: leather showing as milk bucket on 1.21.11
Fixes: coal ore dropping coal ore instead of coal
Fixes: 26.1-exclusive blocks showing as wrong blocks on older clients

* fix(codegen): remove #[must_use] from trait impl methods in generated code

* fix(codegen): switch entity, sound and block state remapping to ViaBackwards mappings

---------

Co-authored-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com>
This commit is contained in:
Nicolai Van der Storm
2026-05-27 15:22:17 +02:00
committed by GitHub
parent d29e4c18bd
commit 42f6b9ce3f
35 changed files with 17301 additions and 15678 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.