mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
More fixed for 1.21.5, 1.21.9, 1.21.11, stress tested against everything from 1.20.6 - 1.21.11
This commit is contained in:
parent
17808bb652
commit
c43b157b55
6 changed files with 76 additions and 11 deletions
|
|
@ -16,7 +16,7 @@ public class InstrumentComponent1215(DataTypes dataTypes, ItemPalette itemPalett
|
|||
var holderId = DataTypes.ReadNextVarInt(data);
|
||||
if (holderId == 0)
|
||||
{
|
||||
// Inline Instrument: SoundEvent holder + VarInt useDuration + Float range + Component description
|
||||
// Inline Instrument: SoundEvent holder + Float useDuration + Float range + Component description
|
||||
var soundHolderId = DataTypes.ReadNextVarInt(data);
|
||||
if (soundHolderId == 0)
|
||||
{
|
||||
|
|
@ -25,9 +25,10 @@ public class InstrumentComponent1215(DataTypes dataTypes, ItemPalette itemPalett
|
|||
if (hasFixedRange)
|
||||
DataTypes.ReadNextFloat(data);
|
||||
}
|
||||
DataTypes.ReadNextVarInt(data); // useDuration
|
||||
DataTypes.ReadNextFloat(data); // useDuration
|
||||
DataTypes.ReadNextFloat(data); // range
|
||||
DataTypes.ReadNextString(data); // description (Component as JSON string)
|
||||
// ComponentSerialization.STREAM_CODEC is NBT-backed, not a plain string.
|
||||
DataTypes.ReadNextNbt(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ public class PaintingVariantHolderComponent(DataTypes dataTypes, ItemPalette ite
|
|||
|
||||
// Optional<Component> title
|
||||
if (DataTypes.ReadNextBool(data))
|
||||
DataTypes.ReadNextString(data);
|
||||
DataTypes.ReadNextNbt(data);
|
||||
|
||||
// Optional<Component> author
|
||||
if (DataTypes.ReadNextBool(data))
|
||||
DataTypes.ReadNextString(data);
|
||||
DataTypes.ReadNextNbt(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ public class ProvidesTrimMaterialComponent(DataTypes dataTypes, ItemPalette item
|
|||
DataTypes.ReadNextString(data); // ResourceKey<EquipmentAsset>
|
||||
DataTypes.ReadNextString(data); // override suffix
|
||||
}
|
||||
// description Component
|
||||
DataTypes.ReadNextString(data);
|
||||
// ComponentSerialization.STREAM_CODEC is NBT-backed, not a plain string.
|
||||
DataTypes.ReadNextNbt(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MinecraftClient.Inventory.ItemPalettes;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_9;
|
||||
|
||||
public class BeesComponent1219(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
||||
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
|
||||
{
|
||||
public int NumberOfBees { get; set; }
|
||||
public List<TypedBee> Bees { get; set; } = [];
|
||||
|
||||
public override void Parse(Queue<byte> data)
|
||||
{
|
||||
NumberOfBees = DataTypes.ReadNextVarInt(data);
|
||||
Bees = new List<TypedBee>(NumberOfBees);
|
||||
|
||||
for (var i = 0; i < NumberOfBees; i++)
|
||||
{
|
||||
Bees.Add(
|
||||
new TypedBee(
|
||||
DataTypes.ReadNextVarInt(data),
|
||||
DataTypes.ReadNextNbt(data),
|
||||
DataTypes.ReadNextVarInt(data),
|
||||
DataTypes.ReadNextVarInt(data)));
|
||||
}
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetVarInt(NumberOfBees));
|
||||
|
||||
if (NumberOfBees != Bees.Count)
|
||||
throw new InvalidOperationException("Can't serialize the BeesComponent1219 because NumberOfBees and Bees.Count differ!");
|
||||
|
||||
foreach (var bee in Bees)
|
||||
{
|
||||
data.AddRange(DataTypes.GetVarInt(bee.EntityTypeId));
|
||||
data.AddRange(DataTypes.GetNbt(bee.EntityDataNbt));
|
||||
data.AddRange(DataTypes.GetVarInt(bee.TicksInHive));
|
||||
data.AddRange(DataTypes.GetVarInt(bee.MinTicksInHive));
|
||||
}
|
||||
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record TypedBee(int EntityTypeId, Dictionary<string, object>? EntityDataNbt, int TicksInHive, int MinTicksInHive);
|
||||
|
|
@ -5,6 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21;
|
|||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_2;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_5;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_8;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_9;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_11;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||
|
||||
|
|
@ -90,7 +91,7 @@ public class StructuredComponentsRegistry12111 : StructuredComponentRegistry
|
|||
RegisterComponent<PotDecorationsComponent>(72, "minecraft:pot_decorations");
|
||||
RegisterComponent<ContainerComponent>(73, "minecraft:container");
|
||||
RegisterComponent<BlockStateComponent>(74, "minecraft:block_state");
|
||||
RegisterComponent<BeesComponent>(75, "minecraft:bees");
|
||||
RegisterComponent<BeesComponent1219>(75, "minecraft:bees");
|
||||
RegisterComponent<LockComponent>(76, "minecraft:lock");
|
||||
RegisterComponent<ContainerLootComponent>(77, "minecraft:container_loot");
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21;
|
|||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_2;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_5;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_8;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_9;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Registries;
|
||||
|
|
@ -14,6 +15,9 @@ public class StructuredComponentsRegistry1215 : StructuredComponentRegistry
|
|||
public StructuredComponentsRegistry1215(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
||||
: base(dataTypes, itemPalette, subComponentRegistry)
|
||||
{
|
||||
var uses1218AttributeAndEquippableFormats = dataTypes.ProtocolVersion >= Protocol18Handler.MC_1_21_6_Version;
|
||||
var usesTypedBeesFormat = dataTypes.ProtocolVersion >= Protocol18Handler.MC_1_21_9_Version;
|
||||
|
||||
RegisterComponent<CustomDataComponent>(0, "minecraft:custom_data");
|
||||
RegisterComponent<MaxStackSizeComponent>(1, "minecraft:max_stack_size");
|
||||
RegisterComponent<MaxDamageComponent>(2, "minecraft:max_damage");
|
||||
|
|
@ -27,7 +31,10 @@ public class StructuredComponentsRegistry1215 : StructuredComponentRegistry
|
|||
RegisterComponent<EnchantmentsComponent1215>(10, "minecraft:enchantments");
|
||||
RegisterComponent<CanPlaceOnComponent>(11, "minecraft:can_place_on");
|
||||
RegisterComponent<CanBreakComponent>(12, "minecraft:can_break");
|
||||
RegisterComponent<AttributeModifiersComponent1215>(13, "minecraft:attribute_modifiers");
|
||||
if (uses1218AttributeAndEquippableFormats)
|
||||
RegisterComponent<AttributeModifiersComponent1218>(13, "minecraft:attribute_modifiers");
|
||||
else
|
||||
RegisterComponent<AttributeModifiersComponent1215>(13, "minecraft:attribute_modifiers");
|
||||
RegisterComponent<CustomModelDataComponent>(14, "minecraft:custom_model_data");
|
||||
// 15: tooltip_display (NEW, replaces hide_additional_tooltip + hide_tooltip)
|
||||
RegisterComponent<TooltipDisplayComponent>(15, "minecraft:tooltip_display");
|
||||
|
|
@ -43,7 +50,10 @@ public class StructuredComponentsRegistry1215 : StructuredComponentRegistry
|
|||
RegisterComponent<ToolComponent1215>(25, "minecraft:tool");
|
||||
RegisterComponent<WeaponComponent>(26, "minecraft:weapon"); // NEW
|
||||
RegisterComponent<EnchantableComponent>(27, "minecraft:enchantable");
|
||||
RegisterComponent<EquippableComponent1215>(28, "minecraft:equippable");
|
||||
if (uses1218AttributeAndEquippableFormats)
|
||||
RegisterComponent<EquippableComponent1218>(28, "minecraft:equippable");
|
||||
else
|
||||
RegisterComponent<EquippableComponent1215>(28, "minecraft:equippable");
|
||||
RegisterComponent<RepairableComponent>(29, "minecraft:repairable");
|
||||
RegisterComponent<GliderComponent>(30, "minecraft:glider");
|
||||
RegisterComponent<TooltipStyleComponent>(31, "minecraft:tooltip_style");
|
||||
|
|
@ -83,7 +93,10 @@ public class StructuredComponentsRegistry1215 : StructuredComponentRegistry
|
|||
RegisterComponent<PotDecorationsComponent>(65, "minecraft:pot_decorations");
|
||||
RegisterComponent<ContainerComponent>(66, "minecraft:container");
|
||||
RegisterComponent<BlockStateComponent>(67, "minecraft:block_state");
|
||||
RegisterComponent<BeesComponent>(68, "minecraft:bees"); // Wire format unchanged in 1.21.5
|
||||
if (usesTypedBeesFormat)
|
||||
RegisterComponent<BeesComponent1219>(68, "minecraft:bees");
|
||||
else
|
||||
RegisterComponent<BeesComponent>(68, "minecraft:bees");
|
||||
RegisterComponent<LockComponent>(69, "minecraft:lock");
|
||||
RegisterComponent<ContainerLootComponent>(70, "minecraft:container_loot");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue