2023-03-24 19:46:25 +08:00
|
|
|
using MinecraftClient.Mapping.EntityMetadataPalettes;
|
|
|
|
|
using MinecraftClient.Protocol.Handlers;
|
|
|
|
|
using System;
|
2023-03-23 23:41:41 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Mapping;
|
|
|
|
|
|
|
|
|
|
public abstract class EntityMetadataPalette
|
|
|
|
|
{
|
|
|
|
|
public abstract Dictionary<int, EntityMetaDataType> GetEntityMetadataMappingsList();
|
2023-03-24 19:46:25 +08:00
|
|
|
|
|
|
|
|
public EntityMetaDataType GetDataType(int typeId)
|
|
|
|
|
{
|
|
|
|
|
return GetEntityMetadataMappingsList()[typeId];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static EntityMetadataPalette GetPalette(int protocolVersion)
|
|
|
|
|
{
|
2023-06-08 19:27:28 +02:00
|
|
|
return protocolVersion switch
|
|
|
|
|
{
|
|
|
|
|
<= Protocol18Handler.MC_1_8_Version => new EntityMetadataPalette18(), // 1.8
|
|
|
|
|
<= Protocol18Handler.MC_1_12_2_Version => new EntityMetadataPalette1122(), // 1.9 - 1.12.2
|
|
|
|
|
<= Protocol18Handler.MC_1_19_2_Version => new EntityMetadataPalette1191(), // 1.13 - 1.19.2
|
|
|
|
|
<= Protocol18Handler.MC_1_19_3_Version => new EntityMetadataPalette1193(), // 1.19.3
|
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
|
|
|
< Protocol18Handler.MC_1_20_6_Version => new EntityMetadataPalette1194(), // 1.19.4 - 1.20.4
|
2026-03-20 23:51:56 +08:00
|
|
|
<= Protocol18Handler.MC_1_21_4_Version => new EntityMetadataPalette1206(), // 1.20.6 - 1.21.4
|
2026-03-21 14:05:06 +08:00
|
|
|
<= Protocol18Handler.MC_1_21_7_Version => new EntityMetadataPalette1215(), // 1.21.5 - 1.21.8
|
|
|
|
|
<= Protocol18Handler.MC_1_21_9_Version => new EntityMetadataPalette1219(), // 1.21.9 - 1.21.10
|
feat: add version routing, structured components, and metadata for MC 1.21.11
- Add MC_1_21_11_Version constant (protocol 774)
- Create StructuredComponentsRegistry12111 with 104 components (8 new:
use_effects, minimum_attack_charge, damage_type, attack_range,
piercing_weapon, kinetic_weapon, swing_animation, zombie_nautilus/variant)
- Add 6 new component classes for 1.21.11 wire formats
- Add RegistryEitherHolderComponent for holderRegistry-backed EitherHolder
- Add ZombieNautilusVariant and HumanoidArm cases in DataTypes.ReadNextMetadata
- Update all version routing in Protocol18, PacketType18Handler,
EntityMetadataPalette, StructuredComponentsHandler, and ProtocolHandler
- Bump MCHighestVersion to 1.21.11
Made-with: Cursor
2026-03-22 00:56:04 +08:00
|
|
|
<= Protocol18Handler.MC_1_21_11_Version => new EntityMetadataPalette12111(), // 1.21.11
|
2026-07-02 16:43:31 -05:00
|
|
|
<= Protocol18Handler.MC_26_2_Version => new EntityMetadataPalette261(), // 26.1 - 26.2 (serializers unchanged in 26.2)
|
2023-06-08 19:27:28 +02:00
|
|
|
_ => throw new NotImplementedException()
|
|
|
|
|
};
|
2023-03-24 19:46:25 +08:00
|
|
|
}
|
2023-03-23 23:41:41 +01:00
|
|
|
}
|