Fixing bugs with island gen

This commit is contained in:
Adubbz 2016-02-06 22:48:12 +11:00
parent 75f50a80a4
commit e35847726a
3 changed files with 22 additions and 14 deletions

View File

@ -198,7 +198,7 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
public static Map<Integer, List<Integer>> subBiomesMap; public static Map<Integer, List<Integer>> subBiomesMap;
public static Map<Integer, List<Integer>> mutatedBiomesMap; public static Map<Integer, List<Integer>> mutatedBiomesMap;
public static ArrayList<WeightedBiomeEntry> islandBiomesList = new ArrayList<WeightedBiomeEntry>(); public static Map<Integer, Integer> islandBiomesMap = new HashMap<Integer, Integer>();
public static int totalIslandBiomesWeight; public static int totalIslandBiomesWeight;
public static void init() public static void init()
@ -396,7 +396,6 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
canyon_ravine = registerBOPBiome(new BiomeGenCanyon(BiomeGenCanyon.CanyonType.RAVINE), "Canyon Ravine"); canyon_ravine = registerBOPBiome(new BiomeGenCanyon(BiomeGenCanyon.CanyonType.RAVINE), "Canyon Ravine");
coral_reef = registerBOPBiome(new BiomeGenCoralReef(), "Coral Reef"); coral_reef = registerBOPBiome(new BiomeGenCoralReef(), "Coral Reef");
kelp_forest = registerBOPBiome(new BiomeGenKelpForest(), "Kelp Forest"); kelp_forest = registerBOPBiome(new BiomeGenKelpForest(), "Kelp Forest");
tropical_island = registerBOPBiome(new BiomeGenTropicalIsland(), "Tropical Island");
setSubBiome(canyon, canyon_ravine); setSubBiome(canyon, canyon_ravine);
setSubBiome(Optional.of(BiomeGenBase.ocean), BOPBiomes.coral_reef); setSubBiome(Optional.of(BiomeGenBase.ocean), BOPBiomes.coral_reef);
@ -404,6 +403,9 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
// island biomes // island biomes
tropical_island = registerBOPBiome(new BiomeGenTropicalIsland(), "Tropical Island");
addIslandBiome(tropical_island, 10);
} }
private static void registerBiomeDictionaryTags() 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<BiomeGenBase> biome, int weight)
{
if (biome.isPresent())
{ {
totalIslandBiomesWeight += weight; totalIslandBiomesWeight += weight;
islandBiomesList.add(new WeightedBiomeEntry(weight, biome)); islandBiomesMap.put(biome.get().biomeID, weight);
}
} }
private static void configureBiome(IExtendedBiome biome, String idName) private static void configureBiome(IExtendedBiome biome, String idName)

View File

@ -13,6 +13,7 @@ import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.IntCache; import net.minecraft.world.gen.layer.IntCache;
import net.minecraftforge.common.BiomeManager.BiomeType; import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.common.enums.BOPClimates; import biomesoplenty.common.enums.BOPClimates;
import biomesoplenty.common.init.ModBiomes;
import biomesoplenty.common.world.BOPWorldSettings; import biomesoplenty.common.world.BOPWorldSettings;
public class GenLayerBiomeBOP extends BOPGenLayer public class GenLayerBiomeBOP extends BOPGenLayer
@ -55,10 +56,10 @@ public class GenLayerBiomeBOP extends BOPGenLayer
{ {
out[index] = climate.getRandomOceanBiome(this, true).biomeID; 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 // keep islands, unless it's in an icy climate in which case, replace
out[index] = BiomeGenBase.mushroomIsland.biomeID; out[index] = landSeaVal;
} }
else if (landSeaVal == 0) else if (landSeaVal == 0)
{ {

View File

@ -8,6 +8,7 @@
package biomesoplenty.common.world.layer; package biomesoplenty.common.world.layer;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry;
import biomesoplenty.common.enums.BOPClimates.WeightedBiomeEntry; import biomesoplenty.common.enums.BOPClimates.WeightedBiomeEntry;
import biomesoplenty.common.init.ModBiomes; import biomesoplenty.common.init.ModBiomes;
@ -42,7 +43,7 @@ public class GenLayerLargeIsland extends BOPGenLayer
this.initChunkSeed((long)(x + areaX), (long)(z + areaY)); 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(); out[x + z * areaWidth] = getRandomIslandBiome();
} }
@ -59,14 +60,15 @@ public class GenLayerLargeIsland extends BOPGenLayer
public int getRandomIslandBiome() public int getRandomIslandBiome()
{ {
int weight = this.nextInt(ModBiomes.totalIslandBiomesWeight); int weight = this.nextInt(ModBiomes.totalIslandBiomesWeight);
Iterator<WeightedBiomeEntry> iterator = ModBiomes.islandBiomesList.iterator(); Iterator<Entry<Integer, Integer>> iterator = ModBiomes.islandBiomesMap.entrySet().iterator();
WeightedBiomeEntry item;
Entry<Integer, Integer> item;
do do
{ {
item = iterator.next(); item = iterator.next();
weight -= item.weight; weight -= item.getValue();
} }
while (weight >= 0); while (weight >= 0);
return item.biome.biomeID; return item.getKey();
} }
} }