From e35847726a8946b7f73bd0fd3e7aeddbdfa8bd69 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sat, 6 Feb 2016 22:48:12 +1100 Subject: [PATCH] Fixing bugs with island gen --- .../biomesoplenty/common/init/ModBiomes.java | 17 +++++++++++------ .../common/world/layer/GenLayerBiomeBOP.java | 7 ++++--- .../common/world/layer/GenLayerLargeIsland.java | 12 +++++++----- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/main/java/biomesoplenty/common/init/ModBiomes.java b/src/main/java/biomesoplenty/common/init/ModBiomes.java index 6c4241365..f0b476cb4 100644 --- a/src/main/java/biomesoplenty/common/init/ModBiomes.java +++ b/src/main/java/biomesoplenty/common/init/ModBiomes.java @@ -198,7 +198,7 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry public static Map> subBiomesMap; public static Map> mutatedBiomesMap; - public static ArrayList islandBiomesList = new ArrayList(); + public static Map islandBiomesMap = new HashMap(); public static int totalIslandBiomesWeight; public static void init() @@ -396,14 +396,16 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry canyon_ravine = registerBOPBiome(new BiomeGenCanyon(BiomeGenCanyon.CanyonType.RAVINE), "Canyon Ravine"); coral_reef = registerBOPBiome(new BiomeGenCoralReef(), "Coral Reef"); kelp_forest = registerBOPBiome(new BiomeGenKelpForest(), "Kelp Forest"); - tropical_island = registerBOPBiome(new BiomeGenTropicalIsland(), "Tropical Island"); - + setSubBiome(canyon, canyon_ravine); setSubBiome(Optional.of(BiomeGenBase.ocean), BOPBiomes.coral_reef); setSubBiome(Optional.of(BiomeGenBase.ocean), BOPBiomes.kelp_forest); // island biomes + tropical_island = registerBOPBiome(new BiomeGenTropicalIsland(), "Tropical Island"); + + addIslandBiome(tropical_island, 10); } private static void registerBiomeDictionaryTags() @@ -574,10 +576,13 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry } } - private static void addIslandBiome(BiomeGenBase biome, int weight) + private static void addIslandBiome(Optional biome, int weight) { - totalIslandBiomesWeight += weight; - islandBiomesList.add(new WeightedBiomeEntry(weight, biome)); + if (biome.isPresent()) + { + totalIslandBiomesWeight += weight; + islandBiomesMap.put(biome.get().biomeID, weight); + } } private static void configureBiome(IExtendedBiome biome, String idName) diff --git a/src/main/java/biomesoplenty/common/world/layer/GenLayerBiomeBOP.java b/src/main/java/biomesoplenty/common/world/layer/GenLayerBiomeBOP.java index 9ff058fff..8121599d6 100644 --- a/src/main/java/biomesoplenty/common/world/layer/GenLayerBiomeBOP.java +++ b/src/main/java/biomesoplenty/common/world/layer/GenLayerBiomeBOP.java @@ -13,6 +13,7 @@ import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.gen.layer.IntCache; import net.minecraftforge.common.BiomeManager.BiomeType; import biomesoplenty.common.enums.BOPClimates; +import biomesoplenty.common.init.ModBiomes; import biomesoplenty.common.world.BOPWorldSettings; public class GenLayerBiomeBOP extends BOPGenLayer @@ -55,10 +56,10 @@ public class GenLayerBiomeBOP extends BOPGenLayer { out[index] = climate.getRandomOceanBiome(this, true).biomeID; } - else if (landSeaVal == BiomeGenBase.mushroomIsland.biomeID && climate.biomeType != BiomeType.ICY) + else if ((landSeaVal == BiomeGenBase.mushroomIsland.biomeID || ModBiomes.islandBiomesMap.containsKey(landSeaVal)) && climate.biomeType != BiomeType.ICY) { - // keep mushroom islands, unless it's in an icy climate in which case, replace - out[index] = BiomeGenBase.mushroomIsland.biomeID; + // keep islands, unless it's in an icy climate in which case, replace + out[index] = landSeaVal; } else if (landSeaVal == 0) { diff --git a/src/main/java/biomesoplenty/common/world/layer/GenLayerLargeIsland.java b/src/main/java/biomesoplenty/common/world/layer/GenLayerLargeIsland.java index 923a8990d..c68b8074d 100644 --- a/src/main/java/biomesoplenty/common/world/layer/GenLayerLargeIsland.java +++ b/src/main/java/biomesoplenty/common/world/layer/GenLayerLargeIsland.java @@ -8,6 +8,7 @@ package biomesoplenty.common.world.layer; import java.util.Iterator; +import java.util.Map.Entry; import biomesoplenty.common.enums.BOPClimates.WeightedBiomeEntry; import biomesoplenty.common.init.ModBiomes; @@ -42,7 +43,7 @@ public class GenLayerLargeIsland extends BOPGenLayer this.initChunkSeed((long)(x + areaX), (long)(z + areaY)); - if (centerVal == 0 && northWestVal == 0 && northEastVal == 0 && southWestVal == 0 && southEastVal == 0 && this.nextInt(50) == 0) + if (centerVal == 0 && northWestVal == 0 && northEastVal == 0 && southWestVal == 0 && southEastVal == 0 && this.nextInt(75) == 0) { out[x + z * areaWidth] = getRandomIslandBiome(); } @@ -59,14 +60,15 @@ public class GenLayerLargeIsland extends BOPGenLayer public int getRandomIslandBiome() { int weight = this.nextInt(ModBiomes.totalIslandBiomesWeight); - Iterator iterator = ModBiomes.islandBiomesList.iterator(); - WeightedBiomeEntry item; + Iterator> iterator = ModBiomes.islandBiomesMap.entrySet().iterator(); + + Entry item; do { item = iterator.next(); - weight -= item.weight; + weight -= item.getValue(); } while (weight >= 0); - return item.biome.biomeID; + return item.getKey(); } }