diff --git a/Content.Client/Gameplay/GameplayStateBase.cs b/Content.Client/Gameplay/GameplayStateBase.cs index 63cbfdb09c..0a695b2c01 100644 --- a/Content.Client/Gameplay/GameplayStateBase.cs +++ b/Content.Client/Gameplay/GameplayStateBase.cs @@ -185,7 +185,7 @@ namespace Content.Client.Gameplay EntityCoordinates coordinates = default; EntityUid? entityToClick = null; - if (args.Viewport is IViewportControl vp) + if (args.Viewport is IViewportControl vp && kArgs.PointerLocation.IsValid) { var mousePosWorld = vp.PixelToMap(kArgs.PointerLocation.Position); entityToClick = GetClickedEntity(mousePosWorld); @@ -194,6 +194,10 @@ namespace Content.Client.Gameplay grid.MapToGrid(mousePosWorld) : EntityCoordinates.FromMap(_mapManager, mousePosWorld); } + else + { + coordinates = EntityCoordinates.Invalid; + } var message = new ClientFullInputCmdMessage(_timing.CurTick, _timing.TickFraction, funcId) { diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index e2bb991318..12c2a396de 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -170,7 +170,7 @@ namespace Content.Server.Hands.Systems private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity) { - if (playerSession?.AttachedEntity is not {Valid: true} player || !Exists(player)) + if (playerSession?.AttachedEntity is not {Valid: true} player || !Exists(player) || !coordinates.IsValid(EntityManager)) return false; return ThrowHeldItem(player, coordinates);