From 5c1512d527d34c7052cd8fac4a27cd14333a353c Mon Sep 17 00:00:00 2001 From: Dizigma Date: Mon, 6 Jul 2015 18:31:13 -0600 Subject: [PATCH] Stopped players from placing blocks on their heads --- TrueCraft.Core/Logic/BlockProvider.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/TrueCraft.Core/Logic/BlockProvider.cs b/TrueCraft.Core/Logic/BlockProvider.cs index d00f794..7ab0c58 100644 --- a/TrueCraft.Core/Logic/BlockProvider.cs +++ b/TrueCraft.Core/Logic/BlockProvider.cs @@ -150,6 +150,15 @@ namespace TrueCraft.Core.Logic } } + // Prevent the user from placing blocks on themselves + var userPlayer = user.Entity as PlayerEntity; + if (userPlayer != null){ + if (new BoundingBox(userPlayer.Position, userPlayer.Position + userPlayer.Size) + .Intersects(box)){ + return; + } + } + // Place block world.SetBlockID(coordinates, ID); world.SetMetadata(coordinates, (byte)item.Metadata);