From def2ca75528c306ad5845f0216ed57522165799a Mon Sep 17 00:00:00 2001 From: SirYwell Date: Wed, 11 May 2022 19:38:28 +0200 Subject: [PATCH] make y location of homes always absolute part 2 --- .../java/com/plotsquared/core/plot/Plot.java | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index b709de857..ff707953a 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -1420,15 +1420,7 @@ public class Plot { 0 ); } - Location location = Location - .at( - bottom.getWorldName(), - bottom.getX() + home.getX(), - bottom.getY() + home.getY(), - bottom.getZ() + home.getZ(), - home.getYaw(), - home.getPitch() - ); + Location location = toHomeLocation(bottom, home); if (!this.worldUtil.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) { location = location.withY( Math.max(1 + this.worldUtil.getHighestBlockSynchronous( @@ -1461,15 +1453,7 @@ public class Plot { return; } Location bottom = this.getBottomAbs(); - Location location = Location - .at( - bottom.getWorldName(), - bottom.getX() + home.getX(), - home.getY(), // y is absolute - bottom.getZ() + home.getZ(), - home.getYaw(), - home.getPitch() - ); + Location location = toHomeLocation(bottom, home); this.worldUtil.getBlock(location, block -> { if (!block.getBlockType().getMaterial().isAir()) { this.worldUtil.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(), @@ -1482,6 +1466,17 @@ public class Plot { } } + private Location toHomeLocation(Location bottom, BlockLoc relativeHome) { + return Location.at( + bottom.getWorldName(), + bottom.getX() + relativeHome.getX(), + relativeHome.getY(), // y is absolute + bottom.getZ() + relativeHome.getZ(), + relativeHome.getYaw(), + relativeHome.getPitch() + ); + } + /** * Sets the home location *