]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Fix spawn chunk outlines again
authorIrtimaled <irtimaled@gmail.com>
Sat, 11 May 2019 19:44:02 +0000 (12:44 -0700)
committerIrtimaled <irtimaled@gmail.com>
Sat, 11 May 2019 19:44:02 +0000 (12:44 -0700)
This was tested with command blocks.  Transpires that when spawn chunk X or Z are divisible by 8 but not 16 there is one extra chunk in negative direction.

src/main/java/com/irtimaled/bbor/client/ClientRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/WorldSpawnRenderer.java
src/main/java/com/irtimaled/bbor/common/MathHelper.java

index bfe2571175c5ba61ba798cab24a92765cddfedf7..11a9ec9afd1c28b8a7b5e8e06e1bf65d11900e7e 100644 (file)
@@ -157,12 +157,14 @@ public class ClientRenderer {
         double midOffset = CHUNK_SIZE * (size / 2.0);
         double midX = Math.round((float) (spawnX / (double) CHUNK_SIZE)) * (double) CHUNK_SIZE;
         double midZ = Math.round((float) (spawnZ / (double) CHUNK_SIZE)) * (double) CHUNK_SIZE;
-        Coords minCoords = new Coords(midX - midOffset, 0, midZ - midOffset);
-        if (spawnX / (double) CHUNK_SIZE % 0.5D == 0.0D && spawnZ / (double) CHUNK_SIZE % 0.5D == 0.0D) {
-            midX += (double) CHUNK_SIZE;
-            midZ += (double) CHUNK_SIZE;
-        }
         Coords maxCoords = new Coords(midX + midOffset, 0, midZ + midOffset);
+        if ((spawnX / (double) CHUNK_SIZE) % 1.0D == 0.5D) {
+            midX -= (double) CHUNK_SIZE;
+        }
+        if ((spawnZ / (double) CHUNK_SIZE) % 1.0D == 0.5D) {
+            midZ -= (double) CHUNK_SIZE;
+        }
+        Coords minCoords = new Coords(midX - midOffset, 0, midZ - midOffset);
         return BoundingBoxWorldSpawn.from(minCoords, maxCoords, type);
     }
 }
index 9ff79dd777b763af6aee4025bd5fcca722c07c1d..1b2ad70b22337277aa9822f8cab2c7de7ddc9a22 100644 (file)
@@ -16,7 +16,7 @@ public class WorldSpawnRenderer extends AbstractRenderer<BoundingBoxWorldSpawn>
 
         double y = PlayerCoords.getMaxY(ConfigManager.worldSpawnMaxY.get()) + 0.001F;
 
-        OffsetBox offsetBox = new OffsetBox(minCoords.getX() + 1, y, minCoords.getZ() + 1, maxCoords.getX() + 1, y, maxCoords.getZ() + 1);
+        OffsetBox offsetBox = new OffsetBox(minCoords.getX(), y, minCoords.getZ(), maxCoords.getX(), y, maxCoords.getZ());
         renderUnfilledCuboid(offsetBox, color);
     }
 }
index e53367976ebf1800fb2a367a734fb604231d4de1..f780c16e53a09770550600eb4bc5e7ca8a44a269 100644 (file)
@@ -3,6 +3,6 @@ package com.irtimaled.bbor.common;
 public class MathHelper {
     public static int floor(double value) {
         int intValue = (int) value;
-        return value > intValue ? intValue : intValue - 1;
+        return value >= intValue ? intValue : intValue - 1;
     }
 }