mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
bugfix: Fix structured components on 26.1
This commit is contained in:
commit
b5af631a40
4 changed files with 124 additions and 7 deletions
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.Inventory.ItemPalettes;
|
||||||
|
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._26_1;
|
||||||
|
|
||||||
|
public class HolderSetComponent261(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
||||||
|
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
|
||||||
|
{
|
||||||
|
public string? TagKey { get; set; }
|
||||||
|
public List<int> HolderIds { get; } = [];
|
||||||
|
|
||||||
|
public override void Parse(Queue<byte> data)
|
||||||
|
{
|
||||||
|
var count = DataTypes.ReadNextVarInt(data) - 1;
|
||||||
|
if (count == -1)
|
||||||
|
{
|
||||||
|
TagKey = DataTypes.ReadNextString(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < count; i++)
|
||||||
|
HolderIds.Add(DataTypes.ReadNextVarInt(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Queue<byte> Serialize()
|
||||||
|
{
|
||||||
|
var bytes = new List<byte>();
|
||||||
|
if (TagKey is not null)
|
||||||
|
{
|
||||||
|
bytes.AddRange(DataTypes.GetVarInt(0));
|
||||||
|
bytes.AddRange(DataTypes.GetString(TagKey));
|
||||||
|
return new Queue<byte>(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes.AddRange(DataTypes.GetVarInt(HolderIds.Count + 1));
|
||||||
|
foreach (var holderId in HolderIds)
|
||||||
|
bytes.AddRange(DataTypes.GetVarInt(holderId));
|
||||||
|
|
||||||
|
return new Queue<byte>(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.Inventory.ItemPalettes;
|
||||||
|
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._26_1;
|
||||||
|
|
||||||
|
public class InstrumentComponent261(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
||||||
|
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
|
||||||
|
{
|
||||||
|
public int HolderId { get; set; }
|
||||||
|
|
||||||
|
public override void Parse(Queue<byte> data)
|
||||||
|
{
|
||||||
|
HolderId = DataTypes.ReadNextVarInt(data);
|
||||||
|
if (HolderId != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var soundHolderId = DataTypes.ReadNextVarInt(data);
|
||||||
|
if (soundHolderId == 0)
|
||||||
|
{
|
||||||
|
DataTypes.ReadNextString(data); // ResourceLocation
|
||||||
|
var hasFixedRange = DataTypes.ReadNextBool(data);
|
||||||
|
if (hasFixedRange)
|
||||||
|
DataTypes.ReadNextFloat(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
DataTypes.ReadNextFloat(data); // useDuration
|
||||||
|
DataTypes.ReadNextFloat(data); // range
|
||||||
|
DataTypes.ReadNextNbt(data); // ComponentSerialization.STREAM_CODEC
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Queue<byte> Serialize()
|
||||||
|
{
|
||||||
|
var bytes = new List<byte>();
|
||||||
|
bytes.AddRange(DataTypes.GetVarInt(HolderId));
|
||||||
|
return new Queue<byte>(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.Inventory.ItemPalettes;
|
||||||
|
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._26_1;
|
||||||
|
|
||||||
|
public class ProvidesTrimMaterialComponent261(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
||||||
|
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
|
||||||
|
{
|
||||||
|
public int HolderId { get; set; }
|
||||||
|
|
||||||
|
public override void Parse(Queue<byte> data)
|
||||||
|
{
|
||||||
|
HolderId = DataTypes.ReadNextVarInt(data);
|
||||||
|
if (HolderId != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DataTypes.ReadNextString(data); // base asset suffix
|
||||||
|
|
||||||
|
var overrideCount = DataTypes.ReadNextVarInt(data);
|
||||||
|
for (var i = 0; i < overrideCount; i++)
|
||||||
|
{
|
||||||
|
DataTypes.ReadNextString(data); // ResourceKey<EquipmentAsset>
|
||||||
|
DataTypes.ReadNextString(data); // override suffix
|
||||||
|
}
|
||||||
|
|
||||||
|
DataTypes.ReadNextNbt(data); // ComponentSerialization.STREAM_CODEC
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Queue<byte> Serialize()
|
||||||
|
{
|
||||||
|
var bytes = new List<byte>();
|
||||||
|
bytes.AddRange(DataTypes.GetVarInt(HolderId));
|
||||||
|
return new Queue<byte>(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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_2;
|
||||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_5;
|
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_5;
|
||||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_11;
|
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_11;
|
||||||
|
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._26_1;
|
||||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||||
|
|
||||||
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Registries;
|
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Registries;
|
||||||
|
|
@ -22,7 +23,7 @@ public class StructuredComponentsRegistry261 : StructuredComponentRegistry
|
||||||
RegisterComponent<UseEffectsComponent>(5, "minecraft:use_effects");
|
RegisterComponent<UseEffectsComponent>(5, "minecraft:use_effects");
|
||||||
RegisterComponent<CustomNameComponent>(6, "minecraft:custom_name");
|
RegisterComponent<CustomNameComponent>(6, "minecraft:custom_name");
|
||||||
RegisterComponent<PotionDurationScaleComponent>(7, "minecraft:minimum_attack_charge");
|
RegisterComponent<PotionDurationScaleComponent>(7, "minecraft:minimum_attack_charge");
|
||||||
RegisterComponent<RegistryEitherHolderComponent>(8, "minecraft:damage_type");
|
RegisterComponent<VarIntComponent>(8, "minecraft:damage_type");
|
||||||
RegisterComponent<ItemNameComponent>(9, "minecraft:item_name");
|
RegisterComponent<ItemNameComponent>(9, "minecraft:item_name");
|
||||||
RegisterComponent<ItemModelComponent>(10, "minecraft:item_model");
|
RegisterComponent<ItemModelComponent>(10, "minecraft:item_model");
|
||||||
RegisterComponent<LoreNameComponent1206>(11, "minecraft:lore");
|
RegisterComponent<LoreNameComponent1206>(11, "minecraft:lore");
|
||||||
|
|
@ -41,7 +42,7 @@ public class StructuredComponentsRegistry261 : StructuredComponentRegistry
|
||||||
RegisterComponent<ConsumableComponent>(24, "minecraft:consumable");
|
RegisterComponent<ConsumableComponent>(24, "minecraft:consumable");
|
||||||
RegisterComponent<UseRemainderComponent>(25, "minecraft:use_remainder");
|
RegisterComponent<UseRemainderComponent>(25, "minecraft:use_remainder");
|
||||||
RegisterComponent<UseCooldownComponent>(26, "minecraft:use_cooldown");
|
RegisterComponent<UseCooldownComponent>(26, "minecraft:use_cooldown");
|
||||||
RegisterComponent<DamageResistantComponent>(27, "minecraft:damage_resistant");
|
RegisterComponent<HolderSetComponent261>(27, "minecraft:damage_resistant");
|
||||||
RegisterComponent<ToolComponent>(28, "minecraft:tool");
|
RegisterComponent<ToolComponent>(28, "minecraft:tool");
|
||||||
RegisterComponent<WeaponComponent>(29, "minecraft:weapon");
|
RegisterComponent<WeaponComponent>(29, "minecraft:weapon");
|
||||||
RegisterComponent<AttackRangeComponent>(30, "minecraft:attack_range");
|
RegisterComponent<AttackRangeComponent>(30, "minecraft:attack_range");
|
||||||
|
|
@ -75,11 +76,11 @@ public class StructuredComponentsRegistry261 : StructuredComponentRegistry
|
||||||
RegisterComponent<EntityDataComponent>(58, "minecraft:entity_data");
|
RegisterComponent<EntityDataComponent>(58, "minecraft:entity_data");
|
||||||
RegisterComponent<BucketEntityDataComponent>(59, "minecraft:bucket_entity_data");
|
RegisterComponent<BucketEntityDataComponent>(59, "minecraft:bucket_entity_data");
|
||||||
RegisterComponent<BlockEntityDataComponent>(60, "minecraft:block_entity_data");
|
RegisterComponent<BlockEntityDataComponent>(60, "minecraft:block_entity_data");
|
||||||
RegisterComponent<InstrumentComponent1215>(61, "minecraft:instrument");
|
RegisterComponent<InstrumentComponent261>(61, "minecraft:instrument");
|
||||||
RegisterComponent<ProvidesTrimMaterialComponent>(62, "minecraft:provides_trim_material");
|
RegisterComponent<ProvidesTrimMaterialComponent261>(62, "minecraft:provides_trim_material");
|
||||||
RegisterComponent<OmniousBottleAmplifierComponent>(63, "minecraft:ominous_bottle_amplifier");
|
RegisterComponent<OmniousBottleAmplifierComponent>(63, "minecraft:ominous_bottle_amplifier");
|
||||||
RegisterComponent<JukeBoxPlayableComponent>(64, "minecraft:jukebox_playable");
|
RegisterComponent<JukeBoxPlayableComponent>(64, "minecraft:jukebox_playable");
|
||||||
RegisterComponent<ProvidesBannerPatternsComponent>(65, "minecraft:provides_banner_patterns");
|
RegisterComponent<HolderSetComponent261>(65, "minecraft:provides_banner_patterns");
|
||||||
RegisterComponent<RecipesComponent>(66, "minecraft:recipes");
|
RegisterComponent<RecipesComponent>(66, "minecraft:recipes");
|
||||||
RegisterComponent<LodestoneTrackerComponent>(67, "minecraft:lodestone_tracker");
|
RegisterComponent<LodestoneTrackerComponent>(67, "minecraft:lodestone_tracker");
|
||||||
RegisterComponent<FireworkExplosionComponent>(68, "minecraft:firework_explosion");
|
RegisterComponent<FireworkExplosionComponent>(68, "minecraft:firework_explosion");
|
||||||
|
|
@ -112,9 +113,9 @@ public class StructuredComponentsRegistry261 : StructuredComponentRegistry
|
||||||
RegisterComponent<VarIntComponent>(94, "minecraft:pig/sound_variant"); // New in 26.1
|
RegisterComponent<VarIntComponent>(94, "minecraft:pig/sound_variant"); // New in 26.1
|
||||||
RegisterComponent<VarIntComponent>(95, "minecraft:cow/variant");
|
RegisterComponent<VarIntComponent>(95, "minecraft:cow/variant");
|
||||||
RegisterComponent<VarIntComponent>(96, "minecraft:cow/sound_variant"); // New in 26.1
|
RegisterComponent<VarIntComponent>(96, "minecraft:cow/sound_variant"); // New in 26.1
|
||||||
RegisterComponent<EitherHolderComponent>(97, "minecraft:chicken/variant");
|
RegisterComponent<VarIntComponent>(97, "minecraft:chicken/variant");
|
||||||
RegisterComponent<VarIntComponent>(98, "minecraft:chicken/sound_variant"); // New in 26.1
|
RegisterComponent<VarIntComponent>(98, "minecraft:chicken/sound_variant"); // New in 26.1
|
||||||
RegisterComponent<RegistryEitherHolderComponent>(99, "minecraft:zombie_nautilus/variant");
|
RegisterComponent<VarIntComponent>(99, "minecraft:zombie_nautilus/variant");
|
||||||
RegisterComponent<VarIntComponent>(100, "minecraft:frog/variant");
|
RegisterComponent<VarIntComponent>(100, "minecraft:frog/variant");
|
||||||
RegisterComponent<VarIntComponent>(101, "minecraft:horse/variant");
|
RegisterComponent<VarIntComponent>(101, "minecraft:horse/variant");
|
||||||
RegisterComponent<PaintingVariantHolderComponent>(102, "minecraft:painting/variant");
|
RegisterComponent<PaintingVariantHolderComponent>(102, "minecraft:painting/variant");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue