Skip to content
This repository has been archived by the owner on Oct 22, 2022. It is now read-only.

Commit

Permalink
Fix crash when player entity is null
Browse files Browse the repository at this point in the history
  • Loading branch information
copygirl committed Mar 11, 2018
1 parent ef2c9e8 commit 327b22c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Client/EntityCarryRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ private CachedCarryableBlock GetCachedBlock(CarriedBlock carried)
public void OnRenderFrame(float deltaTime, EnumRenderStage stage)
{
foreach (var player in API.World.AllPlayers) {
// Player entity may be null in some circumstances.
// Maybe the other player is too far away, so there's
// no entity spawned for them on the client's side?
if (player.Entity == null) continue;

// Don't render anything on the client player if they're in first person.
if ((API.World.Player.CameraMode == EnumCameraMode.FirstPerson)
&& (player == API.World.Player)) continue;
Expand Down
2 changes: 2 additions & 0 deletions src/Handler/CarryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public void OnPress()
if (!world.BlockAccessor.GetBlock(_selectedBlock).IsCarryable()) return;
_action = CurrentAction.PickUp;
} else {
// Place down a block. Make sure it's
// put on a solid top face of a block.
if (!CanPlace(world, selection, carried)) return;
_action = CurrentAction.PlaceDown;
}
Expand Down

0 comments on commit 327b22c

Please sign in to comment.