From 72d9bd0a583ef47e36a39ff1b4694747f5276bd8 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 29 Mar 2023 22:04:21 +1100 Subject: [PATCH] Don't delete virtual hand items on client (#14954) --- Content.Shared/Cuffs/SharedCuffableSystem.cs | 10 +++++----- Content.Shared/Hands/SharedHandVirtualItemSystem.cs | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index 2cf87ea96c..f513bb4aa3 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -134,11 +134,11 @@ namespace Content.Shared.Cuffs private void OnCuffsRemovedFromContainer(EntityUid uid, CuffableComponent component, EntRemovedFromContainerMessage args) { - if (args.Container.ID == component.Container.ID) - { - _handVirtualItem.DeleteInHandsMatching(uid, args.Entity); - UpdateCuffState(uid, component); - } + if (args.Container.ID != component.Container.ID) + return; + + _handVirtualItem.DeleteInHandsMatching(uid, args.Entity); + UpdateCuffState(uid, component); } private void OnCuffsInsertedIntoContainer(EntityUid uid, CuffableComponent component, ContainerModifiedMessage args) diff --git a/Content.Shared/Hands/SharedHandVirtualItemSystem.cs b/Content.Shared/Hands/SharedHandVirtualItemSystem.cs index e33ffdf051..037b36d4a8 100644 --- a/Content.Shared/Hands/SharedHandVirtualItemSystem.cs +++ b/Content.Shared/Hands/SharedHandVirtualItemSystem.cs @@ -48,6 +48,11 @@ public abstract class SharedHandVirtualItemSystem : EntitySystem /// public void DeleteInHandsMatching(EntityUid user, EntityUid matching) { + // Client can't currently predict deleting network entities atm and this might happen due to the + // hands leaving PVS for example, in which case we wish to ignore it. + if (_net.IsClient) + return; + foreach (var hand in _hands.EnumerateHands(user)) { if (TryComp(hand.HeldEntity, out HandVirtualItemComponent? virt) && virt.BlockingEntity == matching) -- 2.51.2