Minecraft-Console-Client/MinecraftClient/Protocol
BruceChen 99ac3d028a Dynamically parse minecraft:attribute registry from server RegistryData
In 1.20.6+, EntityProperties packets reference attributes by VarInt registry
IDs instead of string names. Previously, a hardcoded dictionary of 22 attribute
entries (matching the vanilla 1.20.6 registry) was used to map these IDs back
to names. This works for vanilla servers but would fail silently for modded
servers that add custom attributes — any unknown ID would be reported as
"unknown".

This commit replaces the hardcoded attribute dictionary with dynamic registry
parsing, following the same pattern already used for dimension_type and
chat_type registries:

- World.cs: Add static `attributeIdMap` field, `SetAttributeIdMap()` and
  `GetAttributeNameById()` methods for storing/querying attribute names by
  their VarInt registry IDs.

- Protocol18.cs (RegistryData handler): When the server sends a
  `minecraft:attribute` registry during the Configuration phase, parse all
  entries and store the ID→name mapping. The `minecraft:` prefix is stripped
  from entry names to match the format used in EntityProperties packets
  (e.g. "minecraft:generic.armor" → "generic.armor").

- Protocol18.cs (EntityProperties handler): Remove the hardcoded 22-entry
  `attributeDictionary` and use `World.GetAttributeNameById()` instead.
  Unknown IDs still fall back to "unknown" for safety.

Also closes issue #4 (Disconnect packet extra boolean) — verified that both
Play and Configuration phase Disconnect handlers already use `ReadNextChat()`
(NBT format since 1.20.4+), matching the 1.20.6 protocol spec. No code
changes needed; updated tracking document to mark as closed.

Made-with: Cursor
2026-03-19 01:12:18 +08:00
..
Handlers Dynamically parse minecraft:attribute registry from server RegistryData 2026-03-19 01:12:18 +08:00
Message Add FileInputBot for non-interactive debugging and fix NbtToString crash 2026-03-19 00:45:51 +08:00
ProfileKey Ported to .NET 8 2024-12-22 13:20:04 +01:00
Session Fix session cache serializer failure 2024-12-25 01:28:28 +08:00
DataTypeGenerator.cs Fix xxx.Parse 2022-10-04 11:53:07 +08:00
EntityActionType.cs [SKIP_BUILD] Change file encoding to UTF-8 with BOM 2022-11-28 13:55:05 +08:00
GuidExtensions.cs Fix all warnings & Trim (#2226) 2022-10-02 18:31:08 +08:00
IMinecraftCom.cs 1.20.6 - Not working yet 2024-06-16 01:19:09 +02:00
IMinecraftComHandler.cs First working version, not fully tested 2024-06-30 11:26:41 +02:00
JwtPayloadDecode.cs Fix all warnings & Trim (#2226) 2022-10-02 18:31:08 +08:00
MicrosoftAuthentication.cs fixed typo in word heAlper lol 2024-04-16 21:21:08 +03:00
MojangAPI.cs Implement command completion suggestions. 2022-12-06 15:50:17 +08:00
PlayerInfo.cs Trim 2023-01-14 21:07:09 +08:00
ProtocolHandler.cs Preliminary 1.21 Support 2024-12-06 16:45:48 +01:00
ProxiedWebRequest.cs Tooltip support & Bug fix 2022-12-11 13:00:19 +08:00
ReplayHandler.cs Handle non-interactive terminal environments gracefully 2026-03-19 00:11:13 +08:00