Fix structured components: audit fixes, codec helpers, and serialize implementations

- Fix 5 class naming typos: Unbrekable->Unbreakable, Blook->Book,
  Omnious->Ominous, FoodComponentComponent->FoodComponent
- Fix IntangibleProjectileComponent: extends EmptyComponent (Unit type)
- Delete dead code JukeBoxPlayableComponent.cs (duplicated)
- Implement proper Serialize() on BlocksAttacksComponent,
  KineticWeaponComponent, PiercingWeaponComponent
- Extract shared SoundEventHolder/HolderSet codec helpers into
  StructuredComponentCodecHelpers
- Add TypedEntityDataComponent/TypedBlockEntityDataComponent base classes
  for 1.21.9+ typed entity data format
- Fix variable name: uses1218AttributeAndEquippableFormats ->
  uses1216AttributeAndEquippableFormats
- Add entity data version gate (1.21.9+) to v1215 registry
- Fix chicken/variant and zombie_nautilus/variant component types
- Fix empty packet hang in Protocol18 ReadNextPacket loop
- Add structured components integration test harness
This commit is contained in:
Anon 2026-06-11 21:33:48 +02:00
parent 16637f7eba
commit de96462659
22 changed files with 761 additions and 260 deletions

View file

@ -362,7 +362,10 @@ namespace MinecraftClient.Protocol.Handlers
{
while (socketWrapper.HasDataAvailable())
{
packetQueue.Add(ReadNextPacket(), cancelToken);
var packet = ReadNextPacket();
if (packet.Item1 == -1)
continue;
packetQueue.Add(packet, cancelToken);
if (cancelToken.IsCancellationRequested)
break;
@ -418,7 +421,8 @@ namespace MinecraftClient.Protocol.Handlers
internal Tuple<int, Queue<byte>> ReadNextPacket()
{
var size = dataTypes.ReadNextVarIntRAW(socketWrapper); //Packet size
Queue<byte> packetData = new(socketWrapper.ReadDataRAW(size)); //Packet contents
var rawBytes = socketWrapper.ReadDataRAW(size);
Queue<byte> packetData = new(rawBytes); //Packet contents
var compressed = false;
var sizeUncompressed = 0;
@ -436,6 +440,13 @@ namespace MinecraftClient.Protocol.Handlers
}
}
if (packetData.Count == 0)
{
var rawHex = rawBytes.Length > 0 ? BitConverter.ToString(rawBytes).Replace("-", " ") : "(empty)";
log.Warn($"[DEBUG] Empty packet after decompress: size={size}, sizeUncompressed={sizeUncompressed}, protocol={protocolVersion}, state={currentState}, rawBytes=[{rawHex}]");
return new(-1, packetData);
}
var packetId = dataTypes.ReadNextVarInt(packetData); // Packet ID
LogIncomingPacket(packetId, packetData.Count, size, compressed, sizeUncompressed);
if (handler.GetNetworkPacketCaptureEnabled())