]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Fully stop needing config on BoundingBoxType
authorIrtimaled <irtimaled@gmail.com>
Thu, 7 May 2020 02:47:10 +0000 (19:47 -0700)
committerIrtimaled <irtimaled@gmail.com>
Mon, 18 May 2020 00:31:27 +0000 (17:31 -0700)
src/main/java/com/irtimaled/bbor/client/config/BoundingBoxTypeHelper.java
src/main/java/com/irtimaled/bbor/client/gui/BoundingBoxTypeButton.java
src/main/java/com/irtimaled/bbor/client/models/BoundingBoxBiomeBorder.java
src/main/java/com/irtimaled/bbor/client/models/BoundingBoxConduit.java
src/main/java/com/irtimaled/bbor/common/BoundingBoxType.java
src/main/java/com/irtimaled/bbor/common/messages/BoundingBoxSerializer.java
src/main/java/com/irtimaled/bbor/common/models/AbstractBoundingBox.java
src/main/java/com/irtimaled/bbor/config/ConfigManager.java

index 99539e951b654a012e9c7c73c4aa65595fe8861b..b86346e02a20e0a14af29407c81f5abac4d7063b 100644 (file)
@@ -46,6 +46,10 @@ public class BoundingBoxTypeHelper {
         registerType(BoundingBoxType.RuinedPortal, ConfigManager.drawRuinedPortals);
     }
 
+    public static Setting<Boolean> renderSetting(BoundingBoxType type) {
+        return structureTypeMap.get(type.getName());
+    }
+
     public static boolean shouldRender(BoundingBoxType type) {
         Setting<Boolean> setting = structureTypeMap.get(type.getName());
         return setting != null ? setting.get() : false;
index 938d2f42be5d5673357ab9982de77918711d83bd..7432bf227f0d7733d07a51176fb7af59133da437 100644 (file)
@@ -1,5 +1,6 @@
 package com.irtimaled.bbor.client.gui;
 
+import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.common.BoundingBoxType;
 
 import java.awt.*;
@@ -8,7 +9,7 @@ public class BoundingBoxTypeButton extends BoolSettingButton {
     private final Color color;
 
     BoundingBoxTypeButton(int width, String label, BoundingBoxType type) {
-        super(width, label, type.shouldRenderSetting);
+        super(width, label, BoundingBoxTypeHelper.renderSetting(type));
         color = type.getColor();
     }
 
index 77b81c7d7323fbd73a4cd327570db52ad08988d4..e4c4013cc7e7dd1cec0eecd191b2c371917d2723 100644 (file)
@@ -12,7 +12,7 @@ public class BoundingBoxBiomeBorder extends AbstractBoundingBox {
     private final boolean west;
 
     private BoundingBoxBiomeBorder(Coords coords, boolean north, boolean east, boolean south, boolean west) {
-        super(BoundingBoxType.Custom);
+        super(BoundingBoxType.BiomeBorder);
         this.coords = coords;
         this.north = north;
         this.east = east;
index 878317f8faef4a840b27704fceb0707cb9e61293..3407e26d0a9b85a006fed601e96e08c3539c74cb 100644 (file)
@@ -22,7 +22,7 @@ public class BoundingBoxConduit extends BoundingBoxSphere {
 
     @Override
     public int hashCode() {
-        return TypeHelper.combineHashCodes(getTypeName().hashCode(), getCenter().hashCode());
+        return TypeHelper.combineHashCodes(getType().hashCode(), getCenter().hashCode());
     }
 
     @Override
index 559df88849bf198a5a9478f09f014832c722df9a..ecb128717388ecb4a3af7f53ae743da7e8709662 100644 (file)
@@ -1,8 +1,6 @@
 package com.irtimaled.bbor.common;
 
 import com.irtimaled.bbor.common.models.Colors;
-import com.irtimaled.bbor.config.ConfigManager;
-import com.irtimaled.bbor.config.Setting;
 
 import java.awt.*;
 import java.util.HashMap;
@@ -11,38 +9,39 @@ import java.util.Map;
 public class BoundingBoxType {
     private static final Map<Integer, BoundingBoxType> structureTypeMap = new HashMap<>();
 
-    public static final BoundingBoxType JungleTemple = register(Colors.DARK_GREEN, "Jungle_Pyramid", ConfigManager.drawJungleTemples);
-    public static final BoundingBoxType DesertTemple = register(Color.ORANGE, "Desert_Pyramid", ConfigManager.drawDesertTemples);
-    public static final BoundingBoxType WitchHut = register(Color.BLUE, "Swamp_Hut", ConfigManager.drawWitchHuts);
-    public static final BoundingBoxType OceanMonument = register(Color.CYAN, "Monument", ConfigManager.drawOceanMonuments);
-    public static final BoundingBoxType Shipwreck = register(Color.CYAN, "Shipwreck", ConfigManager.drawShipwrecks);
-    public static final BoundingBoxType OceanRuin = register(Color.CYAN, "Ocean_Ruin", ConfigManager.drawOceanRuins);
-    public static final BoundingBoxType BuriedTreasure = register(Color.CYAN, "Buried_Treasure", ConfigManager.drawBuriedTreasure);
-    public static final BoundingBoxType Stronghold = register(Color.YELLOW, "Stronghold", ConfigManager.drawStrongholds);
-    public static final BoundingBoxType MineShaft = register(Color.LIGHT_GRAY, "Mineshaft", ConfigManager.drawMineShafts);
-    public static final BoundingBoxType NetherFortress = register(Color.RED, "Fortress", ConfigManager.drawNetherFortresses);
-    public static final BoundingBoxType EndCity = register(Color.MAGENTA, "EndCity", ConfigManager.drawEndCities);
-    public static final BoundingBoxType Mansion = register(Colors.BROWN, "Mansion", ConfigManager.drawMansions);
-    public static final BoundingBoxType Igloo = register(Color.WHITE, "Igloo", ConfigManager.drawIgloos);
-    public static final BoundingBoxType PillagerOutpost = register(Color.DARK_GRAY, "Pillager_Outpost", ConfigManager.drawPillagerOutposts);
-    public static final BoundingBoxType WorldSpawn = register(Color.RED, "World_Spawn", ConfigManager.drawWorldSpawn);
-    public static final BoundingBoxType SpawnChunks = register(Color.RED, "Spawn_Chunks", ConfigManager.drawWorldSpawn);
-    public static final BoundingBoxType LazySpawnChunks = register(Color.RED, "Lazy_Chunks", ConfigManager.drawLazySpawnChunks);
-    public static final BoundingBoxType MobSpawner = register(Color.GREEN, "Mob_Spawner", ConfigManager.drawMobSpawners);
-    public static final BoundingBoxType SlimeChunks = register(Colors.DARK_GREEN, "Slime_Chunks", ConfigManager.drawSlimeChunks);
-    public static final BoundingBoxType Village = register(Colors.PURPLE, "Village", ConfigManager.drawVillages);
-    public static final BoundingBoxType VillageSpheres = register(null, "Village Sphere", ConfigManager.drawVillageSpheres);
-    public static final BoundingBoxType AFKSphere = register(Color.RED, "AFK Sphere", ConfigManager.drawAFKSpheres);
-    public static final BoundingBoxType BiomeBorder = register(Color.GREEN, "Biome Border", ConfigManager.drawBiomeBorders);
-    public static final BoundingBoxType Beacon = register(Color.WHITE, "Beacon", ConfigManager.drawBeacons);
-    public static final BoundingBoxType NetherFossil = register(Color.WHITE, "Nether_Fossil", ConfigManager.drawNetherFossils);
-    public static final BoundingBoxType BastionRemnant = register(Color.LIGHT_GRAY, "Bastion_Remnant", ConfigManager.drawBastionRemnants);
-    public static final BoundingBoxType RuinedPortal = register(Colors.COOL_PURPLE, "Ruined_Portal", ConfigManager.drawRuinedPortals);
-    public static final BoundingBoxType Conduit = register(Color.CYAN, "Conduit", ConfigManager.drawConduits);
-    public static final BoundingBoxType Custom = register(Color.WHITE, "Custom", ConfigManager.drawCustomBoxes);
+    public static final BoundingBoxType WorldSpawn = register(Color.RED, "World_Spawn");
+    public static final BoundingBoxType SpawnChunks = register(Color.RED, "Spawn_Chunks");
+    public static final BoundingBoxType LazySpawnChunks = register(Color.RED, "Lazy_Chunks");
+    public static final BoundingBoxType MobSpawner = register(Color.GREEN, "Mob_Spawner");
+    public static final BoundingBoxType SlimeChunks = register(Colors.DARK_GREEN, "Slime_Chunks");
+    public static final BoundingBoxType AFKSphere = register(Color.RED, "AFK Sphere");
+    public static final BoundingBoxType BiomeBorder = register(Color.GREEN, "Biome Border");
+    public static final BoundingBoxType Custom = register(Color.WHITE, "Custom");
+    public static final BoundingBoxType Beacon = register(Color.WHITE, "Beacon");
+    public static final BoundingBoxType Conduit = register(Color.CYAN, "Conduit");
 
-    private static BoundingBoxType register(Color color, String name, Setting<Boolean> shouldRenderSetting) {
-        BoundingBoxType type = structureTypeMap.computeIfAbsent(name.hashCode(), k -> new BoundingBoxType(color, name, shouldRenderSetting));
+    public static final BoundingBoxType JungleTemple = register(Colors.DARK_GREEN, "Jungle_Pyramid");
+    public static final BoundingBoxType DesertTemple = register(Color.ORANGE, "Desert_Pyramid");
+    public static final BoundingBoxType WitchHut = register(Color.BLUE, "Swamp_Hut");
+    public static final BoundingBoxType OceanMonument = register(Color.CYAN, "Monument");
+    public static final BoundingBoxType Shipwreck = register(Color.CYAN, "Shipwreck");
+    public static final BoundingBoxType OceanRuin = register(Color.CYAN, "Ocean_Ruin");
+    public static final BoundingBoxType BuriedTreasure = register(Color.CYAN, "Buried_Treasure");
+    public static final BoundingBoxType Stronghold = register(Color.YELLOW, "Stronghold");
+    public static final BoundingBoxType MineShaft = register(Color.LIGHT_GRAY, "Mineshaft");
+    public static final BoundingBoxType NetherFortress = register(Color.RED, "Fortress");
+    public static final BoundingBoxType EndCity = register(Color.MAGENTA, "EndCity");
+    public static final BoundingBoxType Mansion = register(Colors.BROWN, "Mansion");
+    public static final BoundingBoxType Igloo = register(Color.WHITE, "Igloo");
+    public static final BoundingBoxType PillagerOutpost = register(Color.DARK_GRAY, "Pillager_Outpost");
+    public static final BoundingBoxType Village = register(Colors.PURPLE, "Village");
+    public static final BoundingBoxType VillageSpheres = register(null, "Village Sphere");
+    public static final BoundingBoxType NetherFossil = register(Color.WHITE, "Nether_Fossil");
+    public static final BoundingBoxType BastionRemnant = register(Color.LIGHT_GRAY, "Bastion_Remnant");
+    public static final BoundingBoxType RuinedPortal = register(Colors.COOL_PURPLE, "Ruined_Portal");
+
+    private static BoundingBoxType register(Color color, String name) {
+        BoundingBoxType type = structureTypeMap.computeIfAbsent(name.hashCode(), k -> new BoundingBoxType(color, name));
         StructureProcessor.registerSupportedStructure(type);
         return type;
     }
@@ -53,12 +52,10 @@ public class BoundingBoxType {
 
     private final Color color;
     private final String name;
-    public final Setting<Boolean> shouldRenderSetting;
 
-    private BoundingBoxType(Color color, String name, Setting<Boolean> shouldRenderSetting) {
+    private BoundingBoxType(Color color, String name) {
         this.color = color;
         this.name = name;
-        this.shouldRenderSetting = shouldRenderSetting;
     }
 
     public Color getColor() {
@@ -69,7 +66,16 @@ public class BoundingBoxType {
         return name;
     }
 
-    public Boolean shouldRender() {
-        return shouldRenderSetting.get();
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) return true;
+        if (obj == null || getClass() != obj.getClass()) return false;
+        BoundingBoxType other = (BoundingBoxType) obj;
+        return this.name.equals(other.name);
     }
 }
index 2aa4ff773c03c4548bdc6dc69b74d9c96199d5da..7fdce4220af2c848a867f8efe94826161f4b548b 100644 (file)
@@ -41,7 +41,7 @@ class BoundingBoxSerializer {
 
     private static void serializeStructure(BoundingBoxCuboid boundingBox, PayloadBuilder builder) {
         builder.writeChar('S')
-                .writeInt(boundingBox.getTypeName().hashCode())
+                .writeInt(boundingBox.getType().hashCode())
                 .writeCoords(boundingBox.getMinCoords())
                 .writeCoords(boundingBox.getMaxCoords());
     }
index 535d1cd76154d6bd531a0017a555337b8e5091ae..2c1bae244d7c9061cdaeea02296326eabf13cbe9 100644 (file)
@@ -15,16 +15,8 @@ public abstract class AbstractBoundingBox {
         return type.getColor();
     }
 
-    public Boolean shouldRender() {
-        return type.shouldRender();
-    }
-
     public abstract Boolean intersectsBounds(int minX, int minZ, int maxX, int maxZ);
 
-    public String getTypeName() {
-        return type.getName();
-    }
-
     public BoundingBoxType getType() {
         return type;
     }
index 512bb57b242aced2d282bb3d447bfd926f91ec13..0815a406a64c18c5391a2294592ff8706e1473b1 100644 (file)
@@ -44,7 +44,6 @@ public class ConfigManager {
     public static Setting<Boolean> renderAFKSpawnableBlocks;
     public static Setting<Integer> afkSpawnableBlocksRenderDistance;
     public static Setting<Boolean> drawBeacons;
-    public static Setting<Boolean> drawCustomBoxes;
     public static Setting<Boolean> drawBiomeBorders;
     public static Setting<Boolean> renderOnlyCurrentBiome;
     public static Setting<Integer> biomeBordersRenderDistance;
@@ -64,7 +63,6 @@ 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.");
-        drawCustomBoxes = setup(config, "general", "drawCustomBoxes", true, "If set to true custom bounding boxes will be drawn.");
 
         drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");