]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Fix render distance calculation
authorIrtimaled <irtimaled@gmail.com>
Tue, 19 Nov 2019 06:45:56 +0000 (22:45 -0800)
committerIrtimaled <irtimaled@gmail.com>
Tue, 19 Nov 2019 06:46:16 +0000 (22:46 -0800)
src/main/java/com/irtimaled/bbor/common/models/BoundingBoxCuboid.java

index 077fb280fa76bf4d264073db633abf42a213b35d..1b1663a63681adaf47faf8cd99e43b664503f95f 100644 (file)
@@ -52,9 +52,18 @@ public class BoundingBoxCuboid extends AbstractBoundingBox {
 
     @Override
     public Boolean intersectsBounds(int minX, int minZ, int maxX, int maxZ) {
-        return maxCoords.getX() >= minX &&
-                maxCoords.getZ() >= minZ &&
-                minCoords.getX() <= maxX &&
-                minCoords.getZ() <= maxZ;
+        boolean minXWithinBounds = isBetween(minCoords.getX(), minX, maxX);
+        boolean maxXWithinBounds = isBetween(maxCoords.getX(), minX, maxX);
+        boolean minZWithinBounds = isBetween(minCoords.getZ(), minZ, maxZ);
+        boolean maxZWithinBounds = isBetween(maxCoords.getZ(), minZ, maxZ);
+
+        return (minXWithinBounds && minZWithinBounds) ||
+                (maxXWithinBounds && maxZWithinBounds) ||
+                (minXWithinBounds && maxZWithinBounds) ||
+                (maxXWithinBounds && minZWithinBounds);
+    }
+
+    private boolean isBetween(int val, int min, int max) {
+        return val >= min && val <= max;
     }
 }