From f7ce67ecff74c5439fffa744826773409151efe2 Mon Sep 17 00:00:00 2001 From: William278 Date: Sat, 6 Feb 2021 16:49:12 +0000 Subject: [PATCH] Random teleport will now place the player at the center of block, to help prevent players getting stuck in blocks and being pushed into lava --- .../java/me/william278/huskhomes2/Objects/RandomPoint.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/william278/huskhomes2/Objects/RandomPoint.java b/src/main/java/me/william278/huskhomes2/Objects/RandomPoint.java index 7e8322bd..41ef033e 100644 --- a/src/main/java/me/william278/huskhomes2/Objects/RandomPoint.java +++ b/src/main/java/me/william278/huskhomes2/Objects/RandomPoint.java @@ -36,6 +36,8 @@ public class RandomPoint extends TeleportationPoint { int x; int y = 64; int z; + double blockCenterX = 0.5; + double blockCenterZ = 0.5; int negativeX; int negativeZ; @@ -51,13 +53,15 @@ public class RandomPoint extends TeleportationPoint { negativeZ = random.nextInt(2); if (negativeX == 1) { x = x * -1; + blockCenterX = blockCenterX * -1; } if (negativeZ == 1) { z = z * -1; + blockCenterZ = blockCenterZ * -1; } // Put together random location, get the highest block plus one to determine Y - Location randomLocation = new Location(world, x, y, z); + Location randomLocation = new Location(world, (x + blockCenterX), y, (z + blockCenterZ)); y = world.getHighestBlockYAt(randomLocation) + 1; randomLocation.setY(y);