]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Add: flower forest overlay
authorIrtimaled <irtimaled@gmail.com>
Mon, 24 Aug 2020 00:29:00 +0000 (17:29 -0700)
committerIrtimaled <irtimaled@gmail.com>
Mon, 24 Aug 2020 02:05:59 +0000 (19:05 -0700)
13 files changed:
CONTRIBUTORS.md
src/main/java/com/irtimaled/bbor/client/ClientProxy.java
src/main/java/com/irtimaled/bbor/client/ClientRenderer.java
src/main/java/com/irtimaled/bbor/client/config/BoundingBoxTypeHelper.java
src/main/java/com/irtimaled/bbor/client/config/ConfigManager.java
src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java
src/main/java/com/irtimaled/bbor/client/interop/FlowerForestHelper.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/client/models/BoundingBoxFlowerForest.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/client/providers/FlowerForestProvider.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/client/renderers/AbstractRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/FlowerForestRenderer.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/common/BoundingBoxType.java
src/main/resources/assets/bbor/lang/en_us.json

index ec15f5e541f03de19b406383f483b0d0525617f9..a4459c2186e47609134254021f48e3c68d260854 100644 (file)
@@ -4,3 +4,4 @@
 - cameron-gagnon
 - plusls
 - LoupDuQc
+- OroArmor
index c09764cd08f55fd508af0df7857ccfb5abe04aea..efee94a2b8f889e6f916bdcb95e72b4626500808 100644 (file)
@@ -4,6 +4,7 @@ import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.events.*;
 import com.irtimaled.bbor.client.gui.LoadSavesScreen;
 import com.irtimaled.bbor.client.gui.SettingsScreen;
+import com.irtimaled.bbor.client.interop.FlowerForestHelper;
 import com.irtimaled.bbor.client.keyboard.Key;
 import com.irtimaled.bbor.client.keyboard.KeyListener;
 import com.irtimaled.bbor.client.providers.*;
@@ -77,6 +78,7 @@ public class ClientProxy extends CommonProxy {
     protected void setSeed(long seed) {
         super.setSeed(seed);
         SlimeChunkProvider.setSeed(seed);
+        FlowerForestHelper.setSeed(seed);
     }
 
     @Override
index 49a6afab52758ed4283a72aedca0be9c36a3d5e8..fab8e3bbbd3710fc27d60880db800f4df8bc35b5 100644 (file)
@@ -46,6 +46,7 @@ public class ClientRenderer {
         registerRenderer(BoundingBoxSpawnableBlocks.class, new SpawnableBlocksRenderer());
         registerRenderer(BoundingBoxLine.class, new LineRenderer());
         registerRenderer(BoundingBoxSphere.class, new SphereRenderer());
+        registerRenderer(BoundingBoxFlowerForest.class, new FlowerForestRenderer());
 
         registerProvider(new SlimeChunkProvider());
         registerProvider(new WorldSpawnProvider());
@@ -59,6 +60,7 @@ public class ClientRenderer {
         registerProvider(new SpawnableBlocksProvider());
         registerProvider(new CustomLineProvider());
         registerProvider(new CustomSphereProvider());
+        registerProvider(new FlowerForestProvider());
     }
 
     public static <T extends AbstractBoundingBox> void registerProvider(IBoundingBoxProvider<T> provider) {
index 77818104c20d9d323288ba090981334db2c155a6..36886274407a4456ca893e88d0b7fbf8232595d6 100644 (file)
@@ -25,6 +25,7 @@ public class BoundingBoxTypeHelper {
         registerType(BoundingBoxType.Custom, ConfigManager.drawConduits, ConfigManager.colorCustom);
         registerType(BoundingBoxType.Conduit, ConfigManager.drawConduits, ConfigManager.colorConduits);
         registerType(BoundingBoxType.SpawnableBlocks, ConfigManager.drawSpawnableBlocks, ConfigManager.colorSpawnableBlocks);
+        registerType(BoundingBoxType.FlowerForest, ConfigManager.drawFlowerForests, null);
 
         registerType(BoundingBoxType.JungleTemple, ConfigManager.drawJungleTemples, ConfigManager.colorJungleTemples);
         registerType(BoundingBoxType.DesertTemple, ConfigManager.drawDesertTemples, ConfigManager.colorDesertTemples);
index 6e2f8a3e86cfd1c268a83a5b7210d3d41446dd93..a659e62b47225a3cdfc66ae9f360242c9be0b1f0 100644 (file)
@@ -53,6 +53,8 @@ public class ConfigManager {
     public static Setting<Integer> spawnableBlocksRenderHeight;
     public static Setting<Boolean> invertBoxColorPlayerInside;
     public static Setting<Boolean> renderSphereAsDots;
+    public static Setting<Boolean> drawFlowerForests;
+    public static Setting<Integer> flowerForestsRenderDistance;
 
     public static Setting<HexColor> colorWorldSpawn;
     public static Setting<HexColor> colorLazySpawnChunks;
@@ -87,6 +89,17 @@ public class ConfigManager {
     public static Setting<HexColor> colorNetherFossils;
     public static Setting<HexColor> colorBastionRemnants;
     public static Setting<HexColor> colorRuinedPortals;
+    public static Setting<HexColor> colorFlowerForestDandelion;
+    public static Setting<HexColor> colorFlowerForestPoppy;
+    public static Setting<HexColor> colorFlowerForestAllium;
+    public static Setting<HexColor> colorFlowerForestAzureBluet;
+    public static Setting<HexColor> colorFlowerForestRedTulip;
+    public static Setting<HexColor> colorFlowerForestOrangeTulip;
+    public static Setting<HexColor> colorFlowerForestWhiteTulip;
+    public static Setting<HexColor> colorFlowerForestPinkTulip;
+    public static Setting<HexColor> colorFlowerForestOxeyeDaisy;
+    public static Setting<HexColor> colorFlowerForestCornflower;
+    public static Setting<HexColor> colorFlowerForestLilyOfTheValley;
 
     public static Setting<HexColor> buttonOnOverlay;
 
@@ -113,6 +126,9 @@ public class ConfigManager {
         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.");
 
+        drawFlowerForests = setup(config, "flowerForests", "drawFlowerForests", true, "If set to true flower forest flower overlays will be drawn.");
+        flowerForestsRenderDistance = setup(config, "flowerForests", "flowerForestsRenderDistance", 3, "The distance from the player where flower forests will be drawn.");
+
         drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn.");
         drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn.");
         drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn.");
@@ -184,6 +200,17 @@ public class ConfigManager {
         colorNetherFossils = setup(config, "colors", "colorNetherFossils", HexColor.from("#ffffff"), "Color of nether fossils.");
         colorBastionRemnants = setup(config, "colors", "colorBastionRemnants", HexColor.from("#c0c0c0"), "Color of bastion remnants.");
         colorRuinedPortals = setup(config, "colors", "colorRuinedPortals", HexColor.from("#c800ff"), "Color of ruined portals.");
+        colorFlowerForestDandelion = setup(config, "colors", "colorFlowerForestDandelion", HexColor.from("#ffff00"), "Color of Flower Forest Dandelion");
+        colorFlowerForestPoppy = setup(config, "colors", "colorFlowerForestPoppy", HexColor.from("#ff0000"), "Color of Flower Forest Poppy");
+        colorFlowerForestAllium = setup(config, "colors", "colorFlowerForestAllium", HexColor.from("#ff00ff"), "Color of Flower Forest Allium");
+        colorFlowerForestAzureBluet = setup(config, "colors", "colorFlowerForestAzureBluet", HexColor.from("#d3d3d3"), "Color of Flower Forest Azure Bluet");
+        colorFlowerForestRedTulip = setup(config, "colors", "colorFlowerForestRedTulip", HexColor.from("#ff0000"), "Color of Flower Forest Red Tulip");
+        colorFlowerForestOrangeTulip = setup(config, "colors", "colorFlowerForestOrangeTulip", HexColor.from("#ff681f"), "Color of Flower Forest Orange Tulip");
+        colorFlowerForestWhiteTulip = setup(config, "colors", "colorFlowerForestWhiteTulip", HexColor.from("#d3d3d3"), "Color of Flower Forest White Tulip");
+        colorFlowerForestPinkTulip = setup(config, "colors", "colorFlowerForestPinkTulip", HexColor.from("#ff69b4"), "Color of Flower Forest Pink Tulip");
+        colorFlowerForestOxeyeDaisy = setup(config, "colors", "colorFlowerForestOxeyeDaisy", HexColor.from("#d3d3d3"), "Color of Flower Forest Oxeye Daisy");
+        colorFlowerForestCornflower = setup(config, "colors", "colorFlowerForestCornflower", HexColor.from("#0000ff"), "Color of Flower Forest Cornflower");
+        colorFlowerForestLilyOfTheValley = setup(config, "colors", "colorFlowerForestLilyOfTheValley", HexColor.from("#ffffff"), "Color of Flower Forest Lily Of The Valley");
 
         config.save();
     }
index cce48a2754b5af323a243d9e6a17c082ff424029..28761cc107645c8c7781c78632a06e155133ddc4 100644 (file)
@@ -62,6 +62,12 @@ public class SettingsScreen extends ListScreen {
                                 .addDisplayValue(1, I18n.format("bbor.options.distance.nearest"))
                                 .addDisplayValue(2, I18n.format("bbor.options.distance.nearer"))
                                 .addDisplayValue(3, I18n.format("bbor.options.distance.normal")))
+                .section(I18n.format("bbor.features.flowerForests"),
+                        width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.flowerForests"), BoundingBoxType.FlowerForest),
+                        width -> new IntSettingSlider(width, 1, 3, "bbor.options.distance", ConfigManager.flowerForestsRenderDistance)
+                                .addDisplayValue(1, I18n.format("bbor.options.distance.nearest"))
+                                .addDisplayValue(2, I18n.format("bbor.options.distance.nearer"))
+                                .addDisplayValue(3, I18n.format("bbor.options.distance.normal")))
                 .section(I18n.format("bbor.features.mobSpawners"),
                         width -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.mobSpawners"), BoundingBoxType.MobSpawner),
                         width -> new BoolSettingButton(width, I18n.format("bbor.features.mobSpawners.spawnArea"), ConfigManager.renderMobSpawnerSpawnArea),
diff --git a/src/main/java/com/irtimaled/bbor/client/interop/FlowerForestHelper.java b/src/main/java/com/irtimaled/bbor/client/interop/FlowerForestHelper.java
new file mode 100644 (file)
index 0000000..1d64707
--- /dev/null
@@ -0,0 +1,56 @@
+package com.irtimaled.bbor.client.interop;
+
+import com.irtimaled.bbor.client.config.ConfigManager;
+import com.irtimaled.bbor.client.config.HexColor;
+import com.irtimaled.bbor.client.config.Setting;
+import com.irtimaled.bbor.common.models.Coords;
+import net.minecraft.block.BlockState;
+import net.minecraft.block.Blocks;
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.biome.Biomes;
+import net.minecraft.world.gen.feature.DecoratedFeatureConfig;
+import net.minecraft.world.gen.feature.FlowersFeature;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+public class FlowerForestHelper {
+    private static final Random random = new Random();
+
+    private static final Map<BlockState, Setting<HexColor>> flowerColorMap = new HashMap<>();
+    private static final FlowersFeature flowersFeature;
+
+    static {
+        flowerColorMap.put(Blocks.DANDELION.getDefaultState(), ConfigManager.colorFlowerForestDandelion);
+        flowerColorMap.put(Blocks.POPPY.getDefaultState(), ConfigManager.colorFlowerForestPoppy);
+        flowerColorMap.put(Blocks.ALLIUM.getDefaultState(), ConfigManager.colorFlowerForestAllium);
+        flowerColorMap.put(Blocks.AZURE_BLUET.getDefaultState(), ConfigManager.colorFlowerForestAzureBluet);
+        flowerColorMap.put(Blocks.RED_TULIP.getDefaultState(), ConfigManager.colorFlowerForestRedTulip);
+        flowerColorMap.put(Blocks.ORANGE_TULIP.getDefaultState(), ConfigManager.colorFlowerForestOrangeTulip);
+        flowerColorMap.put(Blocks.WHITE_TULIP.getDefaultState(), ConfigManager.colorFlowerForestWhiteTulip);
+        flowerColorMap.put(Blocks.PINK_TULIP.getDefaultState(), ConfigManager.colorFlowerForestPinkTulip);
+        flowerColorMap.put(Blocks.OXEYE_DAISY.getDefaultState(), ConfigManager.colorFlowerForestOxeyeDaisy);
+        flowerColorMap.put(Blocks.CORNFLOWER.getDefaultState(), ConfigManager.colorFlowerForestCornflower);
+        flowerColorMap.put(Blocks.LILY_OF_THE_VALLEY.getDefaultState(), ConfigManager.colorFlowerForestLilyOfTheValley);
+
+        DecoratedFeatureConfig config = (DecoratedFeatureConfig) Biomes.FLOWER_FOREST.getFlowers().get(0).config;
+        flowersFeature = (FlowersFeature) config.feature.feature;
+    }
+
+    public static Setting<HexColor> getFlowerColorAtPos(Coords coords) {
+        int x = coords.getX();
+        int z = coords.getZ();
+        BlockState blockState = flowersFeature.getRandomFlower(random, new BlockPos(x, coords.getY(), z));
+        return flowerColorMap.get(blockState);
+    }
+
+    public static void setSeed(long seed) {
+        random.setSeed(seed);
+    }
+
+    public static boolean canGrowFlower(int x, int y, int z) {
+        return Minecraft.getInstance().world.getBlockState(new BlockPos(x, y, z)).getBlock() == Blocks.GRASS_BLOCK;
+    }
+}
diff --git a/src/main/java/com/irtimaled/bbor/client/models/BoundingBoxFlowerForest.java b/src/main/java/com/irtimaled/bbor/client/models/BoundingBoxFlowerForest.java
new file mode 100644 (file)
index 0000000..2f598cd
--- /dev/null
@@ -0,0 +1,49 @@
+package com.irtimaled.bbor.client.models;
+
+import com.irtimaled.bbor.client.config.ColorHelper;
+import com.irtimaled.bbor.client.config.HexColor;
+import com.irtimaled.bbor.client.config.Setting;
+import com.irtimaled.bbor.common.BoundingBoxType;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
+import com.irtimaled.bbor.common.models.Coords;
+
+import java.awt.*;
+
+public class BoundingBoxFlowerForest extends AbstractBoundingBox {
+    private final Coords coords;
+    private final Setting<HexColor> colorSetting;
+
+    public BoundingBoxFlowerForest(Coords coords, Setting<HexColor> colorSetting) {
+        super(BoundingBoxType.FlowerForest);
+        this.coords = coords;
+        this.colorSetting = colorSetting;
+    }
+
+    @Override
+    public Boolean intersectsBounds(int minX, int minZ, int maxX, int maxZ) {
+        return coords.getX() >= minX && coords.getZ() >= minZ && coords.getX() <= maxX && coords.getZ() <= maxZ;
+    }
+
+    public Color getColor() {
+        return ColorHelper.getColor(colorSetting);
+    }
+
+    public Coords getCoords() {
+        return coords;
+    }
+
+    @Override
+    public double getDistanceX(double x) {
+        return x - coords.getX();
+    }
+
+    @Override
+    public double getDistanceY(double y) {
+        return y - coords.getY();
+    }
+
+    @Override
+    public double getDistanceZ(double z) {
+        return z - coords.getZ();
+    }
+}
diff --git a/src/main/java/com/irtimaled/bbor/client/providers/FlowerForestProvider.java b/src/main/java/com/irtimaled/bbor/client/providers/FlowerForestProvider.java
new file mode 100644 (file)
index 0000000..cd6b46a
--- /dev/null
@@ -0,0 +1,88 @@
+package com.irtimaled.bbor.client.providers;
+
+import com.irtimaled.bbor.client.Player;
+import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
+import com.irtimaled.bbor.client.config.ConfigManager;
+import com.irtimaled.bbor.client.interop.BiomeBorderHelper;
+import com.irtimaled.bbor.client.interop.FlowerForestHelper;
+import com.irtimaled.bbor.client.models.BoundingBoxFlowerForest;
+import com.irtimaled.bbor.common.BoundingBoxType;
+import com.irtimaled.bbor.common.MathHelper;
+import com.irtimaled.bbor.common.models.Coords;
+import com.irtimaled.bbor.common.models.DimensionId;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.biome.Biomes;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class FlowerForestProvider implements IBoundingBoxProvider<BoundingBoxFlowerForest> {
+    public static final int FLOWER_FOREST_BIOME_ID = Registry.BIOME.getId(Biomes.FLOWER_FOREST);
+    private static Coords lastPlayerCoords = null;
+    private static Integer lastRenderDistance = null;
+    private static Map<Coords, BoundingBoxFlowerForest> lastBoundingBoxes = new HashMap<>();
+
+    @Override
+    public boolean canProvide(DimensionId dimensionId) {
+        return BoundingBoxTypeHelper.shouldRender(BoundingBoxType.FlowerForest);
+    }
+
+    @Override
+    public Iterable<BoundingBoxFlowerForest> get(DimensionId dimensionId) {
+        Coords playerCoords = Player.getCoords();
+        Integer renderDistance = ConfigManager.flowerForestsRenderDistance.get();
+        if (!playerCoords.equals(lastPlayerCoords) || !renderDistance.equals(lastRenderDistance)) {
+            lastPlayerCoords = playerCoords;
+            lastRenderDistance = renderDistance;
+            lastBoundingBoxes = getBoundingBoxes();
+        }
+        return lastBoundingBoxes.values();
+    }
+
+    public static void clear() {
+        lastBoundingBoxes = new HashMap<>();
+        lastPlayerCoords = null;
+    }
+
+    private Map<Coords, BoundingBoxFlowerForest> getBoundingBoxes() {
+        int renderDistance = lastRenderDistance;
+        Coords playerCoords = lastPlayerCoords;
+
+        int width = MathHelper.floor(Math.pow(2, 2 + renderDistance));
+
+        int blockX = playerCoords.getX();
+        int minX = blockX - width;
+        int maxX = blockX + width;
+
+        int blockZ = playerCoords.getZ();
+        int minZ = blockZ - width;
+        int maxZ = blockZ + width;
+
+        Map<Coords, BoundingBoxFlowerForest> boundingBoxes = new HashMap<>();
+        for (int x = minX; x <= maxX; x++) {
+            for (int z = minZ; z <= maxZ; z++) {
+                int biomeId = BiomeBorderHelper.getBiomeId(x, 255, z);
+                if (biomeId == FLOWER_FOREST_BIOME_ID) {
+                    int y = getMaxYForPos(x, playerCoords.getY() + 1, z);
+                    if (y == 0) {
+                        continue;
+                    }
+                    Coords coords = new Coords(x, y + 1, z);
+                    BoundingBoxFlowerForest boundingBox = lastBoundingBoxes.containsKey(coords)
+                            ? lastBoundingBoxes.get(coords)
+                            : new BoundingBoxFlowerForest(coords, FlowerForestHelper.getFlowerColorAtPos(coords));
+                    boundingBoxes.put(coords, boundingBox);
+                }
+            }
+        }
+        return boundingBoxes;
+    }
+
+    private static int getMaxYForPos(int x, int y, int z) {
+        while (y > 0) {
+            if (FlowerForestHelper.canGrowFlower(x, y, z)) return y;
+            y--;
+        }
+        return 0;
+    }
+}
index de227735639eedd7bc8e4366a23f1113fdea0fb3..26f2279f645b928f30977c1dbaad818b51401d9f 100644 (file)
@@ -106,11 +106,15 @@ public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
     }
 
     void renderFilledFaces(OffsetPoint min, OffsetPoint max, Color color) {
+        renderFilledFaces(min, max, color, 30);
+    }
+
+    void renderFilledFaces(OffsetPoint min, OffsetPoint max, Color color, int alpha) {
         if (!ConfigManager.fill.get()) return;
 
         RenderHelper.polygonModeFill();
         RenderHelper.enableBlend();
-        renderFaces(min, max, color, 30, Renderer::startQuads);
+        renderFaces(min, max, color, alpha, Renderer::startQuads);
         RenderHelper.disableBlend();
         RenderHelper.enablePolygonOffsetLine();
         RenderHelper.polygonOffsetMinusOne();
diff --git a/src/main/java/com/irtimaled/bbor/client/renderers/FlowerForestRenderer.java b/src/main/java/com/irtimaled/bbor/client/renderers/FlowerForestRenderer.java
new file mode 100644 (file)
index 0000000..570e202
--- /dev/null
@@ -0,0 +1,17 @@
+package com.irtimaled.bbor.client.renderers;
+
+import com.irtimaled.bbor.client.models.BoundingBoxFlowerForest;
+import com.irtimaled.bbor.common.models.Coords;
+
+public class FlowerForestRenderer extends AbstractRenderer<BoundingBoxFlowerForest> {
+    @Override
+    public void render(BoundingBoxFlowerForest boundingBox) {
+        Coords coords = boundingBox.getCoords();
+        int x = coords.getX();
+        int y = coords.getY();
+        int z = coords.getZ();
+        renderFilledFaces(new OffsetPoint(x, y + 0.01d, z),
+                new OffsetPoint(x + 1, y + 0.01d, z + 1),
+                boundingBox.getColor(), 127);
+    }
+}
index 9c1a9b66901db3bd85694df807f08643bea92ba8..65728f61eb5b3b7a0c9f328eb4594c0d124ad009 100644 (file)
@@ -17,6 +17,7 @@ public class BoundingBoxType {
     public static final BoundingBoxType Beacon = register("Beacon");
     public static final BoundingBoxType Conduit = register("Conduit");
     public static final BoundingBoxType SpawnableBlocks = register("Spawnable Blocks");
+    public static final BoundingBoxType FlowerForest = register("Flower Forest");
 
     public static final BoundingBoxType JungleTemple = register("Jungle_Pyramid");
     public static final BoundingBoxType DesertTemple = register("Desert_Pyramid");
index ac14fa30a4c46f51e5f38a066e11003ae920db68..c531bd0a2bff1d796788c6eb1475ed25e8f7be15 100644 (file)
@@ -29,6 +29,7 @@
   "bbor.features.spawningSpheres": "Spawning Spheres",
   "bbor.features.spawnableBlocks": "Spawnable Blocks",
   "bbor.features.biomeBorders": "Biome Borders",
+  "bbor.features.flowerForests": "Flower Forests",
 
   "bbor.sections.beaconsAndConduits": "Beacons & Conduits",
   "bbor.features.beacons": "Beacons",