From fa71f6379db8d8e54f5fef438e0b9e6d909569d0 Mon Sep 17 00:00:00 2001 From: Picono435 Date: Tue, 27 Dec 2022 13:49:50 +0000 Subject: [PATCH] Fixed issue with max-distance config not being 100% reliable --- .../java/com/gmail/picono435/randomtp/api/RandomTPAPI.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/gmail/picono435/randomtp/api/RandomTPAPI.java b/common/src/main/java/com/gmail/picono435/randomtp/api/RandomTPAPI.java index fedd4ab..755ab79 100644 --- a/common/src/main/java/com/gmail/picono435/randomtp/api/RandomTPAPI.java +++ b/common/src/main/java/com/gmail/picono435/randomtp/api/RandomTPAPI.java @@ -114,7 +114,7 @@ private static Pair generateCoordinates(ServerLevel world, Pla if(random.nextInt(2) == 1) { // Calculating X coordinates from min to max int maxDistance = Config.getMaxDistance() == 0 ? (int) world.getWorldBorder().getMinX() : (int) (player.getX() + Config.getMaxDistance()); - if(maxDistance < world.getWorldBorder().getMaxX()) maxDistance = (int) world.getWorldBorder().getMinX(); + if(maxDistance < world.getWorldBorder().getMinX()) maxDistance = (int) world.getWorldBorder().getMinX(); int minDistance = (int) (player.getX() - Config.getMinDistance()); if(minDistance < world.getWorldBorder().getMinX()) minDistance = (int) (world.getWorldBorder().getMinX() + 10); if(maxDistance < minDistance) maxDistance = maxDistance ^ minDistance ^ (minDistance = maxDistance); @@ -134,7 +134,7 @@ private static Pair generateCoordinates(ServerLevel world, Pla if(random.nextInt(2) == 1) { // Calculating Z coordinates from min to max int maxDistance = Config.getMaxDistance() == 0 ? (int) world.getWorldBorder().getMinZ() : (int) (player.getZ() + Config.getMaxDistance()); - if(maxDistance < world.getWorldBorder().getMaxZ()) maxDistance = (int) world.getWorldBorder().getMinZ(); + if(maxDistance < world.getWorldBorder().getMinZ()) maxDistance = (int) world.getWorldBorder().getMinZ(); int minDistance = (int) (player.getZ() - Config.getMinDistance()); if(minDistance < world.getWorldBorder().getMinZ()) minDistance = (int) (world.getWorldBorder().getMinZ() + 10); if(maxDistance < minDistance) maxDistance = maxDistance ^ minDistance ^ (minDistance = maxDistance);