Enhance EntityMetadataUpdateProcessor to ensure container/storage metadata is always synchronized to visible players and allow updates from any player for such metadata.
This commit is contained in:
@@ -39,19 +39,33 @@ public class EntityMetadataUpdateProcessor : AuthenticatedPacketProcessor<Entity
|
||||
{
|
||||
bool updateVisibleToPlayer = player.CanSee(entity);
|
||||
|
||||
if (player != sendingPlayer && updateVisibleToPlayer)
|
||||
// Always sync container/storage metadata to all visible players
|
||||
bool isContainerMetadata = IsContainerRelatedMetadata(packet.NewValue);
|
||||
|
||||
if (player != sendingPlayer && (updateVisibleToPlayer || isContainerMetadata))
|
||||
{
|
||||
player.SendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsContainerRelatedMetadata(EntityMetadata metadata)
|
||||
{
|
||||
// Check if metadata is related to containers/storage
|
||||
return metadata.GetType().Name.Contains("Container") ||
|
||||
metadata.GetType().Name.Contains("Storage") ||
|
||||
metadata.GetType().Name.Contains("Inventory");
|
||||
}
|
||||
|
||||
private bool TryProcessMetadata(Player sendingPlayer, Entity entity, EntityMetadata metadata)
|
||||
{
|
||||
return metadata switch
|
||||
{
|
||||
PlayerMetadata playerMetadata => ProcessPlayerMetadata(sendingPlayer, entity, playerMetadata),
|
||||
|
||||
// Always allow container/storage metadata updates for proper sync
|
||||
_ when IsContainerRelatedMetadata(metadata) => true,
|
||||
|
||||
// Allow metadata updates from any player by default
|
||||
_ => true
|
||||
};
|
||||
|
Reference in New Issue
Block a user