Minecraft-Console-Client/MinecraftClient/Mapping/EntityMetaDataType.cs
BruceChen e1cb18c6f8 fix: add EntityMetadataPalette1206 for correct 1.20.6+ entity metadata parsing
1.20.6 introduced three new EntityDataSerializer types compared to 1.20.4:
- PARTICLES (id 18) - list of particles, inserted after PARTICLE
- WOLF_VARIANT (id 23) - wolf variant holder, inserted after CAT_VARIANT
- ARMADILLO_STATE (id 28) - armadillo state, inserted after SNIFFER_STATE

These insertions shifted subsequent serializer IDs, causing the 1.19.4
palette (EntityMetadataPalette1194) to misidentify metadata types on
1.20.6+ servers. This could lead to incorrect byte consumption and
potential packet parse failures when entities with affected metadata
types (e.g. wolves, armadillos, area effect clouds with particles)
were present.

Changes:
- Add Particles, WolfVariant, ArmadilloState to EntityMetaDataType enum
- Create EntityMetadataPalette1206 with correct 31-entry ID mapping
- Route 1.20.6+ to the new palette in EntityMetadataPalette.GetPalette()
- Add read logic for the three new types in DataTypes.cs

Verified on 1.21.1 vanilla server: cat, wolf, frog, armadillo, painting
entities all spawn without metadata parse errors.

Made-with: Cursor
2026-03-20 01:43:48 +08:00

88 lines
No EOL
1.6 KiB
C#

namespace MinecraftClient.Mapping;
public enum EntityMetaDataType
{
Byte,
Short, // 1.8 only
Int, // 1.8 only
Vector3Int, // 1.8 only (not used by the game)
VarInt,
VarLong,
Float,
String,
Chat,
OptionalChat,
Slot,
Boolean,
/// <summary>
/// Float x3
/// </summary>
Rotation,
Position,
OptionalPosition,
/// <summary>
/// VarInt
/// </summary>
Direction,
OptionalUuid,
/// <summary>
/// VarInt
/// </summary>
BlockId,
/// <summary>
/// VarInt (0 for absent)
/// </summary>
OptionalBlockId,
Nbt,
Particle,
/// <summary>
/// List of Particle (1.20.6+)
/// </summary>
Particles,
/// <summary>
/// VarInt x3
/// </summary>
VillagerData,
OptionalVarInt,
/// <summary>
/// VarInt
/// </summary>
Pose,
/// <summary>
/// VarInt
/// </summary>
CatVariant,
/// <summary>
/// VarInt (1.20.6+)
/// </summary>
WolfVariant,
FrogVariant,
/// <summary>
/// String + Position
/// </summary>
GlobalPosition,
/// <summary>
/// Boolean + String + Position
/// </summary>
OptionalGlobalPosition,
/// <summary>
/// VarInt
/// </summary>
PaintingVariant,
/// <summary>
/// VarInt
/// </summary>
SnifferState,
/// <summary>
/// VarInt (1.20.6+)
/// </summary>
ArmadilloState,
/// <summary>
/// Float x3
/// </summary>
Vector3,
/// <summary>
/// Float x4
/// </summary>
Quaternion
}