]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Add max Y configuration for Biome Borders
authorIrtimaled <irtimaled@gmail.com>
Wed, 8 Apr 2020 09:53:51 +0000 (02:53 -0700)
committerIrtimaled <irtimaled@gmail.com>
Mon, 18 May 2020 00:28:01 +0000 (17:28 -0700)
src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java
src/main/java/com/irtimaled/bbor/client/providers/BiomeBorderProvider.java
src/main/java/com/irtimaled/bbor/config/ConfigManager.java

index f2af58f5a86e05825bc4fc8eb1e273f73a20e8e3..c777e0983426ec9b460d71d983953176571a741a 100644 (file)
@@ -150,7 +150,7 @@ public class SettingsScreen extends GuiScreen {
                         .addDisplayValue(3, "Normal"),
 
                 (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Biome Borders", BoundingBoxType.BiomeBorder),
-                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Only This Biome", ConfigManager.renderOnlyCurrentBiome),
+                (id, x, y, width) -> new MaxYSettingSlider(id, x, y, width, 1, ConfigManager.biomeBordersMaxY),
                 (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 3, "Distance", ConfigManager.biomeBordersRenderDistance)
                         .addDisplayValue(1, "Nearest")
                         .addDisplayValue(2, "Nearer")
index 51f384668c2880888f4d0fec6bc8528675b44389..feaefcac0b962fcc2acf257a8a731544b245dc1e 100644 (file)
@@ -15,6 +15,7 @@ public class BiomeBorderProvider implements IBoundingBoxProvider<BoundingBoxBiom
     private static Coords lastPlayerCoords = null;
     private static Boolean lastRenderAllTransitions = null;
     private static Integer lastRenderDistance = null;
+    private static Integer lastMaxY = null;
     private static Map<Coords, BoundingBoxBiomeBorder> lastBorders = new HashMap<>();
 
     public Iterable<BoundingBoxBiomeBorder> get(int dimensionId) {
@@ -24,10 +25,15 @@ public class BiomeBorderProvider implements IBoundingBoxProvider<BoundingBoxBiom
         Coords playerCoords = Player.getCoords();
         Integer renderDistance = ConfigManager.biomeBordersRenderDistance.get();
         Boolean renderAllTransitions = !ConfigManager.renderOnlyCurrentBiome.get();
-        if (!playerCoords.equals(lastPlayerCoords) || !renderDistance.equals(lastRenderDistance) || renderAllTransitions != lastRenderAllTransitions) {
+        Integer maxY = (int)Player.getMaxY(ConfigManager.biomeBordersMaxY.get());
+        if (!playerCoords.equals(lastPlayerCoords) ||
+                !renderDistance.equals(lastRenderDistance) ||
+                renderAllTransitions != lastRenderAllTransitions ||
+                !maxY.equals(lastMaxY)) {
             lastPlayerCoords = playerCoords;
             lastRenderDistance = renderDistance;
             lastRenderAllTransitions = renderAllTransitions;
+            lastMaxY = maxY;
             lastBorders = getBiomeBorders();
         }
         return lastBorders.values();
@@ -39,17 +45,17 @@ public class BiomeBorderProvider implements IBoundingBoxProvider<BoundingBoxBiom
     }
 
     private Map<Coords, BoundingBoxBiomeBorder> getBiomeBorders() {
-        Integer renderDistance = lastRenderDistance;
+        int renderDistance = lastRenderDistance;
         Coords playerCoords = lastPlayerCoords;
         boolean renderAllTransitions = lastRenderAllTransitions;
+        int maxY = lastMaxY;
 
         int width = MathHelper.floor(Math.pow(2, 3 + renderDistance));
+
         int blockX = playerCoords.getX();
         int minX = blockX - width;
         int maxX = blockX + width;
 
-        int blockY = playerCoords.getY();
-
         int blockZ = playerCoords.getZ();
         int minZ = blockZ - width;
         int maxZ = blockZ + width;
@@ -60,7 +66,7 @@ public class BiomeBorderProvider implements IBoundingBoxProvider<BoundingBoxBiom
             int matchX = (x - minX);
             for (int z = minZ; z <= maxZ; z++) {
                 int matchZ = (z - minZ);
-                biomeIds[matchX][matchZ] = BiomeBorderHelper.getBiomeId(x, blockY, z);
+                biomeIds[matchX][matchZ] = BiomeBorderHelper.getBiomeId(x, maxY, z);
             }
         }
 
@@ -73,7 +79,7 @@ public class BiomeBorderProvider implements IBoundingBoxProvider<BoundingBoxBiom
                 int z = matchZ + minZ;
                 int biomeId = biomeIds[matchX][matchZ];
                 if (renderAllTransitions || biomeId == playerBiomeId) {
-                    Coords coords = new Coords(x, blockY, z);
+                    Coords coords = new Coords(x, maxY, z);
                     if (lastBorders.containsKey(coords)) {
                         borders.put(coords, lastBorders.get(coords));
                     } else {
index 832607dcaee957ec8e4b4f4bcceeaecc556f34b3..26f14215836bacd96886790c47b2f5de8760a9ec 100644 (file)
@@ -48,6 +48,7 @@ public class ConfigManager {
     public static Setting<Boolean> drawBiomeBorders;
     public static Setting<Boolean> renderOnlyCurrentBiome;
     public static Setting<Integer> biomeBordersRenderDistance;
+    public static Setting<Integer> biomeBordersMaxY;
 
     public static void loadConfig(File mcConfigDir) {
         configDir = new File(mcConfigDir, "config");
@@ -63,6 +64,7 @@ public class ConfigManager {
         drawBiomeBorders = setup(config, "biomeBorders", "drawBiomeBorders", true, "If set to true biome borders will be drawn.");
         renderOnlyCurrentBiome = setup(config, "biomeBorders", "renderOnlyCurrentBiome", true, "If set to true only the biome border for the current biome will be drawn.");
         biomeBordersRenderDistance = setup(config, "biomeBorders", "biomeBordersRenderDistance", 3, "The distance from the player where biome borders will be drawn.");
+        biomeBordersMaxY = setup(config, "biomeBorders", "biomeBordersMaxY", -1, "The maximum top of the biome borders. If set to -1 it will use the value when activated, if set to 0 it will always track the players feet.");
 
         drawVillageSpheres = setup(config, "villages", "drawVillageSpheres", true, "If set to true village bounding spheres are drawn.");
         drawIronGolemSpawnArea = setup(config, "villages", "drawIronGolemSpawnArea", true, "If set to true the iron golem spawn area of the village will be drawn. (default:true)");