]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Allow bounding box player inside to be color inverted
authorIrtimaled <irtimaled@gmail.com>
Sun, 10 May 2020 23:17:12 +0000 (16:17 -0700)
committerIrtimaled <irtimaled@gmail.com>
Mon, 18 May 2020 00:31:27 +0000 (17:31 -0700)
src/main/java/com/irtimaled/bbor/client/config/ConfigManager.java
src/main/java/com/irtimaled/bbor/client/renderers/AbstractRenderer.java

index 13773de56c93463209281b8268722ffe67257945..2196d30fefcd22fda58ac6dc6551a97862053356 100644 (file)
@@ -56,6 +56,7 @@ public class ConfigManager {
     public static Setting<Boolean> drawSpawnableBlocks;
     public static Setting<Integer> spawnableBlocksRenderWidth;
     public static Setting<Integer> spawnableBlocksRenderHeight;
+    public static Setting<Boolean> invertBoxColorPlayerInside;
 
     public static void loadConfig() {
         configDir = new File(".", "config");
@@ -66,6 +67,7 @@ public class ConfigManager {
         outerBoxesOnly = setup(config, "general", "outerBoxesOnly", false, "If set to true only the outer bounding boxes are rendered.");
         alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
         keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
+        invertBoxColorPlayerInside = setup(config, "general", "invertBoxColorPlayerInside", false, "If set to true the color of any bounding box the player is inside will be inverted.");
 
         drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");
 
index d701e47e133a19df7eda7370d7ec129f4402eb55..d4e0d8fb04d1203a45bf3aa4a52314ff817bec40 100644 (file)
@@ -39,6 +39,11 @@ public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
         double maxY = max.getY();
         double maxZ = max.getZ();
 
+        if(ConfigManager.invertBoxColorPlayerInside.get() &&
+                playerInsideBoundingBox(minX, minY, minZ, maxX, maxY, maxZ)) {
+            color = new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue());
+        }
+
         Renderer renderer = Renderer.startQuads()
                 .setColor(color)
                 .setAlpha(alpha);
@@ -86,6 +91,10 @@ public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
         renderer.render();
     }
 
+    private boolean playerInsideBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
+        return minX < 0 && maxX > 0 && minY < 0 && maxY > 0 && minZ < 0 && maxZ > 0;
+    }
+
     void renderLine(OffsetPoint startPoint, OffsetPoint endPoint, Color color) {
         GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
         Renderer.startLines()