mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-29 13:04:59 +00:00
fix: resolve entity tracking, container interaction, and enchantment mapping issues for 1.21
- SpawnEntity packet handler now registers non-player entities via OnSpawnEntity for protocol >= 1.20.2 (previously only players were tracked, causing 'entity near' to find nothing) - PlaceBlock gains lookAtBlock option that sends a position/rotation update before the block placement packet, fixing containers not opening via useblock - Enchantment registry IDs are now dynamically parsed from server RegistryData (minecraft:enchantment), fixing incorrect enchantment name display in 1.21 - AttributeModifiersComponent uses base SubComponent type to avoid InvalidCastException when parsing 1.21-specific attribute subcomponents Made-with: Cursor
This commit is contained in:
parent
7609832976
commit
896263acc8
5 changed files with 98 additions and 10 deletions
|
|
@ -465,10 +465,12 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
var isChat = registryId == "minecraft:chat_type";
|
||||
var isDimension = registryId == "minecraft:dimension_type";
|
||||
var isAttribute = registryId == "minecraft:attribute";
|
||||
var isEnchantment = registryId == "minecraft:enchantment";
|
||||
|
||||
var availableChats = isChat ? new Dictionary<int, string>() : null;
|
||||
var dimensionIdMap = isDimension ? new Dictionary<int, string>() : null;
|
||||
var attributeIdMap = isAttribute ? new Dictionary<int, string>() : null;
|
||||
var enchantmentIdMap = isEnchantment ? new Dictionary<int, string>() : null;
|
||||
|
||||
for (var i = 0; i < entryCount; i++)
|
||||
{
|
||||
|
|
@ -489,12 +491,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else if (isAttribute)
|
||||
{
|
||||
// Strip "minecraft:" prefix to match the format used in EntityProperties packets
|
||||
var attrName = entryId.StartsWith("minecraft:")
|
||||
? entryId.Substring("minecraft:".Length)
|
||||
: entryId;
|
||||
attributeIdMap!.Add(i, attrName);
|
||||
}
|
||||
else if (isEnchantment)
|
||||
enchantmentIdMap!.Add(i, entryId);
|
||||
}
|
||||
|
||||
if (isChat)
|
||||
|
|
@ -507,6 +510,8 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else if (isAttribute)
|
||||
World.SetAttributeIdMap(attributeIdMap!);
|
||||
else if (isEnchantment)
|
||||
EnchantmentMapping.SetDynamicEnchantmentIdMap(enchantmentIdMap!);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -2339,6 +2344,8 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
if (entity.Type == EntityType.Player)
|
||||
handler.OnSpawnPlayer(entity.ID, entity.UUID, entity.Location, (byte)entity.Yaw, (byte)entity.Pitch);
|
||||
else
|
||||
handler.OnSpawnEntity(entity);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.Inventory.ItemPalettes;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6;
|
||||
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
|
||||
|
|
@ -11,7 +10,7 @@ public class AttributeModifiersComponent(DataTypes dataTypes, ItemPalette itemPa
|
|||
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
|
||||
{
|
||||
public int NumberOfAttributes { get; set; }
|
||||
public List<AttributeSubComponent> Attributes { get; set; } = new();
|
||||
public List<SubComponent> Attributes { get; set; } = new();
|
||||
public bool ShowInTooltip { get; set; }
|
||||
|
||||
public override void Parse(Queue<byte> data)
|
||||
|
|
@ -19,7 +18,7 @@ public class AttributeModifiersComponent(DataTypes dataTypes, ItemPalette itemPa
|
|||
NumberOfAttributes = dataTypes.ReadNextVarInt(data);
|
||||
|
||||
for (var i = 0; i < NumberOfAttributes; i++)
|
||||
Attributes.Add((AttributeSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.Attribute, data));
|
||||
Attributes.Add(subComponentRegistry.ParseSubComponent(SubComponents.Attribute, data));
|
||||
|
||||
ShowInTooltip = dataTypes.ReadNextBool(data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue