Added support for biome weights

This commit is contained in:
Adubbz 2014-01-17 11:30:25 +11:00
parent fae2540ef1
commit 0bd30c648a
6 changed files with 149 additions and 108 deletions

View File

@ -1,8 +1,9 @@
package biomesoplenty.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.biome.BiomeGenBase;
import org.apache.commons.lang3.StringUtils;
@ -12,9 +13,9 @@ import biomesoplenty.common.world.GenLayerBiomeBOP;
public class BOPBiomeHelper
{
public static HashMap<String, BOPBiomeListEntry> biomeList = new HashMap();
public static HashMap<String, BOPBiomeEntry> biomeList = new HashMap();
public static void registerBiome(BOPBiomeListEntry biome, String name)
public static void registerBiome(BOPBiomeEntry biome, String name)
{
biomeList.put(name, biome);
}
@ -34,7 +35,7 @@ public class BOPBiomeHelper
return StringUtils.remove(StringUtils.uncapitalize(WordUtils.capitalize(originalName)), " ");
}
public static ArrayList<BiomeGenBase> getCorrespondingTemperatureTypeList(TemperatureType type)
public static List<BOPBiomeEntry> getCorrespondingTemperatureTypeList(TemperatureType type)
{
switch (type)
{
@ -60,13 +61,14 @@ public class BOPBiomeHelper
HOT, WARM, COOL, ICY;
}
public static class BOPBiomeListEntry
public static class BOPBiomeEntry extends WeightedRandom.Item
{
public BiomeGenBase biome;
public TemperatureType temperatureType;
public BOPBiomeListEntry(BiomeGenBase biome, TemperatureType temperatureType)
public BOPBiomeEntry(BiomeGenBase biome, TemperatureType temperatureType, int weight)
{
super(weight);
this.biome = biome;
this.temperatureType = temperatureType;
}

View File

@ -10,7 +10,7 @@ import org.apache.commons.lang3.text.WordUtils;
import org.apache.logging.log4j.Level;
import biomesoplenty.api.BOPBiomeHelper;
import biomesoplenty.api.BOPBiomeHelper.BOPBiomeListEntry;
import biomesoplenty.api.BOPBiomeHelper.BOPBiomeEntry;
import biomesoplenty.common.world.GenLayerBiomeBOP;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
@ -35,7 +35,7 @@ public class BOPConfigurationBiomeGen
{
config.load();
for (BOPBiomeListEntry entry : BOPBiomeHelper.biomeList.values())
for (BOPBiomeEntry entry : BOPBiomeHelper.biomeList.values())
{
BiomeGenBase biome = entry.biome;
@ -44,7 +44,7 @@ public class BOPConfigurationBiomeGen
if (config.get("Biomes To Generate (There must be at least one from each category)", name + " (" + WordUtils.capitalize(entry.temperatureType.toString().toLowerCase()) + ")", !disabledBiomes.contains(convertedName)).getBoolean(!disabledBiomes.contains(convertedName)))
{
BOPBiomeHelper.getCorrespondingTemperatureTypeList(entry.temperatureType).add(biome);
BOPBiomeHelper.getCorrespondingTemperatureTypeList(entry.temperatureType).add(entry);
}
}

View File

@ -10,7 +10,7 @@ import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.Level;
import biomesoplenty.api.BOPBiomeHelper;
import biomesoplenty.api.BOPBiomeHelper.BOPBiomeListEntry;
import biomesoplenty.api.BOPBiomeHelper.BOPBiomeEntry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
@ -111,7 +111,7 @@ public class BOPConfigurationStrongholds
{
config.load();
for (BOPBiomeListEntry entry : BOPBiomeHelper.biomeList.values())
for (BOPBiomeEntry entry : BOPBiomeHelper.biomeList.values())
{
BiomeGenBase biome = entry.biome;

View File

@ -11,7 +11,7 @@ import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.config.Configuration;
import biomesoplenty.api.BOPBiomeHelper;
import biomesoplenty.api.BOPBiomeHelper.BOPBiomeListEntry;
import biomesoplenty.api.BOPBiomeHelper.BOPBiomeEntry;
public class BOPConfigurationVillages
{
@ -106,7 +106,7 @@ public class BOPConfigurationVillages
villageDistance = config.get("Biomes O\' Plenty World Type Settings", "Distance between villages", 32, "In Vanilla it is set to 32").getInt();
if (villageDistance < 8) villageDistance = 8;
for (BOPBiomeListEntry entry : BOPBiomeHelper.biomeList.values())
for (BOPBiomeEntry entry : BOPBiomeHelper.biomeList.values())
{
BiomeGenBase biome = entry.biome;

View File

@ -6,7 +6,7 @@ import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.common.BiomeManager;
import biomesoplenty.api.BOPBiomeHelper;
import biomesoplenty.api.BOPBiomeHelper.BOPBiomeListEntry;
import biomesoplenty.api.BOPBiomeHelper.BOPBiomeEntry;
import biomesoplenty.api.BOPBiomeHelper.TemperatureType;
import biomesoplenty.common.biomes.BiomeGenAlps;
import biomesoplenty.common.biomes.BiomeGenArctic;
@ -87,89 +87,89 @@ public class BOPBiomes
private static void registerBiomes()
{
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.desert, TemperatureType.HOT));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.desert, TemperatureType.HOT));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.desert, TemperatureType.HOT));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.field_150588_X, TemperatureType.HOT));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.field_150588_X, TemperatureType.HOT));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.plains, TemperatureType.HOT));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.desert, TemperatureType.HOT, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.desert, TemperatureType.HOT, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.desert, TemperatureType.HOT, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.field_150588_X, TemperatureType.HOT, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.field_150588_X, TemperatureType.HOT, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.plains, TemperatureType.HOT, 50));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.forest, TemperatureType.WARM));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.field_150585_R, TemperatureType.WARM));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.extremeHills, TemperatureType.WARM));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.plains, TemperatureType.WARM));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.field_150583_P, TemperatureType.WARM));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.swampland, TemperatureType.WARM));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.forest, TemperatureType.WARM, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.field_150585_R, TemperatureType.WARM, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.extremeHills, TemperatureType.WARM, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.plains, TemperatureType.WARM, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.field_150583_P, TemperatureType.WARM, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.swampland, TemperatureType.WARM, 50));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.forest, TemperatureType.COOL));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.extremeHills, TemperatureType.COOL));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.taiga, TemperatureType.COOL));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.plains, TemperatureType.COOL));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.forest, TemperatureType.COOL, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.extremeHills, TemperatureType.COOL, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.taiga, TemperatureType.COOL, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.plains, TemperatureType.COOL, 50));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.icePlains, TemperatureType.ICY));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.icePlains, TemperatureType.ICY));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.icePlains, TemperatureType.ICY));
registerVanillaBiome(new BOPBiomeListEntry(BiomeGenBase.field_150584_S, TemperatureType.ICY));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.icePlains, TemperatureType.ICY, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.icePlains, TemperatureType.ICY, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.icePlains, TemperatureType.ICY, 50));
registerVanillaBiome(new BOPBiomeEntry(BiomeGenBase.field_150584_S, TemperatureType.ICY, 50));
registerBiome(new BOPBiomeListEntry(new BiomeGenAlps(BOPConfigurationIDs.alpsID).setBiomeName("Alps"), TemperatureType.ICY));
registerBiome(new BOPBiomeListEntry(new BiomeGenArctic(BOPConfigurationIDs.arcticID).setBiomeName("Arctic"), TemperatureType.ICY));
registerBiome(new BOPBiomeListEntry(new BiomeGenBambooForest(BOPConfigurationIDs.bambooForestID).setBiomeName("Bamboo Forest"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenBayou(BOPConfigurationIDs.bayouID).setBiomeName("Bayou"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenBog(BOPConfigurationIDs.bogID).setBiomeName("Bog"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenBorealForest(BOPConfigurationIDs.borealForestID).setBiomeName("Boreal Forest"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenBrushland(BOPConfigurationIDs.brushlandID).setBiomeName("Brushland"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenCanyon(BOPConfigurationIDs.canyonID).setBiomeName("Canyon"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenChaparral(BOPConfigurationIDs.chaparralID).setBiomeName("Chaparral"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenCherryBlossomGrove(BOPConfigurationIDs.cherryBlossomGroveID).setBiomeName("Cherry Blossom Grove"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenConiferousForest(BOPConfigurationIDs.coniferousForestID).setBiomeName("Coniferous Forest"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenConiferousForestSnow(BOPConfigurationIDs.coniferousForestSnowID).setBiomeName("Snowy Coniferous Forest"), TemperatureType.ICY));
registerBiome(new BOPBiomeListEntry(new BiomeGenCrag(BOPConfigurationIDs.cragID).setBiomeName("Crag"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenDeadForest(BOPConfigurationIDs.deadForestID).setBiomeName("Dead Forest"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenDeadSwamp(BOPConfigurationIDs.deadSwampID).setBiomeName("Dead Swamp"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenDeciduousForest(BOPConfigurationIDs.deciduousForestID).setBiomeName("Deciduous Forest"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenDunes(BOPConfigurationIDs.dunesID).setBiomeName("Dunes"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenFen(BOPConfigurationIDs.fenID).setBiomeName("Fen"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenFlowerField(BOPConfigurationIDs.flowerFieldID).setBiomeName("Flower Field"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenFrostForest(BOPConfigurationIDs.frostForestID).setBiomeName("Frost Forest"), TemperatureType.ICY));
registerBiome(new BOPBiomeListEntry(new BiomeGenGrassland(BOPConfigurationIDs.grasslandID).setBiomeName("Grassland"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenGrove(BOPConfigurationIDs.groveID).setBiomeName("Grove"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenHeathland(BOPConfigurationIDs.heathlandID).setBiomeName("Heathland"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenHighland(BOPConfigurationIDs.highlandID).setBiomeName("Highland"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenJadeCliffs(BOPConfigurationIDs.jadeCliffsID).setBiomeName("Jade Cliffs"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenLavenderFields(BOPConfigurationIDs.lavenderFieldsID).setBiomeName("Lavender Fields"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenLushDesert(BOPConfigurationIDs.lushDesertID).setBiomeName("Lush Desert"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenLushSwamp(BOPConfigurationIDs.lushSwampID).setBiomeName("Lush Swamp"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenMapleWoods(BOPConfigurationIDs.mapleWoodsID).setBiomeName("Maple Woods"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenMarsh(BOPConfigurationIDs.marshID).setBiomeName("Marsh"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenMeadow(BOPConfigurationIDs.meadowID).setBiomeName("Meadow"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenMoor(BOPConfigurationIDs.moorID).setBiomeName("Moor"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenMountain(BOPConfigurationIDs.mountainID).setBiomeName("Mountain"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenMysticGrove(BOPConfigurationIDs.mysticGroveID).setBiomeName("Mystic Grove"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenOminousWoods(BOPConfigurationIDs.ominousWoodsID).setBiomeName("Ominous Woods"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenOriginValley(BOPConfigurationIDs.originValleyID).setBiomeName("Origin Valley"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenOutback(BOPConfigurationIDs.outbackID).setBiomeName("Outback"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenPasture(BOPConfigurationIDs.pastureID).setBiomeName("Pasture"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenPrairie(BOPConfigurationIDs.prairieID).setBiomeName("Prairie"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenQuagmire(BOPConfigurationIDs.quagmireID).setBiomeName("Quagmire"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenRainforest(BOPConfigurationIDs.rainforestID).setBiomeName("Rainforest"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenRedwoodForest(BOPConfigurationIDs.redwoodForestID).setBiomeName("Redwood Forest"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenSacredSprings(BOPConfigurationIDs.sacredSpringsID).setBiomeName("Sacred Springs"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenSeasonalForest(BOPConfigurationIDs.seasonalForestID).setBiomeName("Seasonal Forest"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenShield(BOPConfigurationIDs.shieldID).setBiomeName("Shield"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenShrubland(BOPConfigurationIDs.shrublandID).setBiomeName("Shrubland"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenSilkglades(BOPConfigurationIDs.silkgladesID).setBiomeName("Silkglades"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenSludgepit(BOPConfigurationIDs.sludgepitID).setBiomeName("Sludgepit"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenSpruceWoods(BOPConfigurationIDs.spruceWoodsID).setBiomeName("Spruce Woods"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenTemperateRainforest(BOPConfigurationIDs.temperateRainforestID).setBiomeName("Temperate Rainforest"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenThicket(BOPConfigurationIDs.thicketID).setBiomeName("Thicket"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenTimber(BOPConfigurationIDs.timberID).setBiomeName("Timber"), TemperatureType.COOL));
registerBiome(new BOPBiomeListEntry(new BiomeGenTropicalRainforest(BOPConfigurationIDs.tropicalRainforestID).setBiomeName("Tropical Rainforest"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenTropics(BOPConfigurationIDs.tropicsID).setBiomeName("Tropics"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenTundra(BOPConfigurationIDs.tundraID).setBiomeName("Tundra"), TemperatureType.ICY));
registerBiome(new BOPBiomeListEntry(new BiomeGenVolcano(BOPConfigurationIDs.volcanoID).setBiomeName("Volcano"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenWasteland(BOPConfigurationIDs.wastelandID).setBiomeName("Wasteland"), TemperatureType.HOT));
registerBiome(new BOPBiomeListEntry(new BiomeGenWetland(BOPConfigurationIDs.wetlandID).setBiomeName("Wetland"), TemperatureType.WARM));
registerBiome(new BOPBiomeListEntry(new BiomeGenWoodland(BOPConfigurationIDs.woodlandID).setBiomeName("Woodland"), TemperatureType.WARM));
registerBiome(new BOPBiomeEntry(new BiomeGenAlps(BOPConfigurationIDs.alpsID).setBiomeName("Alps"), TemperatureType.ICY, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenArctic(BOPConfigurationIDs.arcticID).setBiomeName("Arctic"), TemperatureType.ICY, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenBambooForest(BOPConfigurationIDs.bambooForestID).setBiomeName("Bamboo Forest"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenBayou(BOPConfigurationIDs.bayouID).setBiomeName("Bayou"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenBog(BOPConfigurationIDs.bogID).setBiomeName("Bog"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenBorealForest(BOPConfigurationIDs.borealForestID).setBiomeName("Boreal Forest"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenBrushland(BOPConfigurationIDs.brushlandID).setBiomeName("Brushland"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenCanyon(BOPConfigurationIDs.canyonID).setBiomeName("Canyon"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenChaparral(BOPConfigurationIDs.chaparralID).setBiomeName("Chaparral"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenCherryBlossomGrove(BOPConfigurationIDs.cherryBlossomGroveID).setBiomeName("Cherry Blossom Grove"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenConiferousForest(BOPConfigurationIDs.coniferousForestID).setBiomeName("Coniferous Forest"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenConiferousForestSnow(BOPConfigurationIDs.coniferousForestSnowID).setBiomeName("Snowy Coniferous Forest"), TemperatureType.ICY, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenCrag(BOPConfigurationIDs.cragID).setBiomeName("Crag"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenDeadForest(BOPConfigurationIDs.deadForestID).setBiomeName("Dead Forest"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenDeadSwamp(BOPConfigurationIDs.deadSwampID).setBiomeName("Dead Swamp"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenDeciduousForest(BOPConfigurationIDs.deciduousForestID).setBiomeName("Deciduous Forest"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenDunes(BOPConfigurationIDs.dunesID).setBiomeName("Dunes"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenFen(BOPConfigurationIDs.fenID).setBiomeName("Fen"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenFlowerField(BOPConfigurationIDs.flowerFieldID).setBiomeName("Flower Field"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenFrostForest(BOPConfigurationIDs.frostForestID).setBiomeName("Frost Forest"), TemperatureType.ICY, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenGrassland(BOPConfigurationIDs.grasslandID).setBiomeName("Grassland"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenGrove(BOPConfigurationIDs.groveID).setBiomeName("Grove"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenHeathland(BOPConfigurationIDs.heathlandID).setBiomeName("Heathland"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenHighland(BOPConfigurationIDs.highlandID).setBiomeName("Highland"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenJadeCliffs(BOPConfigurationIDs.jadeCliffsID).setBiomeName("Jade Cliffs"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenLavenderFields(BOPConfigurationIDs.lavenderFieldsID).setBiomeName("Lavender Fields"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenLushDesert(BOPConfigurationIDs.lushDesertID).setBiomeName("Lush Desert"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenLushSwamp(BOPConfigurationIDs.lushSwampID).setBiomeName("Lush Swamp"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenMapleWoods(BOPConfigurationIDs.mapleWoodsID).setBiomeName("Maple Woods"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenMarsh(BOPConfigurationIDs.marshID).setBiomeName("Marsh"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenMeadow(BOPConfigurationIDs.meadowID).setBiomeName("Meadow"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenMoor(BOPConfigurationIDs.moorID).setBiomeName("Moor"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenMountain(BOPConfigurationIDs.mountainID).setBiomeName("Mountain"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenMysticGrove(BOPConfigurationIDs.mysticGroveID).setBiomeName("Mystic Grove"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenOminousWoods(BOPConfigurationIDs.ominousWoodsID).setBiomeName("Ominous Woods"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenOriginValley(BOPConfigurationIDs.originValleyID).setBiomeName("Origin Valley"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenOutback(BOPConfigurationIDs.outbackID).setBiomeName("Outback"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenPasture(BOPConfigurationIDs.pastureID).setBiomeName("Pasture"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenPrairie(BOPConfigurationIDs.prairieID).setBiomeName("Prairie"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenQuagmire(BOPConfigurationIDs.quagmireID).setBiomeName("Quagmire"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenRainforest(BOPConfigurationIDs.rainforestID).setBiomeName("Rainforest"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenRedwoodForest(BOPConfigurationIDs.redwoodForestID).setBiomeName("Redwood Forest"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenSacredSprings(BOPConfigurationIDs.sacredSpringsID).setBiomeName("Sacred Springs"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenSeasonalForest(BOPConfigurationIDs.seasonalForestID).setBiomeName("Seasonal Forest"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenShield(BOPConfigurationIDs.shieldID).setBiomeName("Shield"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenShrubland(BOPConfigurationIDs.shrublandID).setBiomeName("Shrubland"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenSilkglades(BOPConfigurationIDs.silkgladesID).setBiomeName("Silkglades"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenSludgepit(BOPConfigurationIDs.sludgepitID).setBiomeName("Sludgepit"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenSpruceWoods(BOPConfigurationIDs.spruceWoodsID).setBiomeName("Spruce Woods"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenTemperateRainforest(BOPConfigurationIDs.temperateRainforestID).setBiomeName("Temperate Rainforest"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenThicket(BOPConfigurationIDs.thicketID).setBiomeName("Thicket"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenTimber(BOPConfigurationIDs.timberID).setBiomeName("Timber"), TemperatureType.COOL, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenTropicalRainforest(BOPConfigurationIDs.tropicalRainforestID).setBiomeName("Tropical Rainforest"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenTropics(BOPConfigurationIDs.tropicsID).setBiomeName("Tropics"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenTundra(BOPConfigurationIDs.tundraID).setBiomeName("Tundra"), TemperatureType.ICY, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenVolcano(BOPConfigurationIDs.volcanoID).setBiomeName("Volcano"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenWasteland(BOPConfigurationIDs.wastelandID).setBiomeName("Wasteland"), TemperatureType.HOT, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenWetland(BOPConfigurationIDs.wetlandID).setBiomeName("Wetland"), TemperatureType.WARM, 50));
registerBiome(new BOPBiomeEntry(new BiomeGenWoodland(BOPConfigurationIDs.woodlandID).setBiomeName("Woodland"), TemperatureType.WARM, 50));
}
private static void addSpawnBiomes()
@ -186,7 +186,7 @@ public class BOPBiomes
}
else
{
for (BOPBiomeListEntry entry : BOPBiomeHelper.biomeList.values())
for (BOPBiomeEntry entry : BOPBiomeHelper.biomeList.values())
{
addSpawnBiome(entry.biome);
}
@ -328,24 +328,24 @@ public class BOPBiomes
BiomeDictionary.registerBiomeType(BOPBiomeHelper.getBOPBiome("woodland"), Type.FOREST);
}
public static void registerOnlyBiome(BOPBiomeListEntry biome)
public static void registerOnlyBiome(BOPBiomeEntry biome)
{
onlyBiome = biome.biome;
}
public static void registerVanillaBiome(BOPBiomeListEntry biome)
public static void registerVanillaBiome(BOPBiomeEntry biome)
{
BOPBiomeHelper.registerBiome(biome, "minecraft:" + BOPBiomeHelper.convertBiomeName(biome.biome.biomeName));
}
public static void registerBiome(BOPBiomeListEntry biome)
public static void registerBiome(BOPBiomeEntry biome)
{
BOPBiomeHelper.registerBiome(biome, "biomesoplenty:" + BOPBiomeHelper.convertBiomeName(biome.biome.biomeName));
}
public static void addBiomeToList(BOPBiomeListEntry biome)
public static void addBiomeToList(BOPBiomeEntry biome)
{
BOPBiomeHelper.getCorrespondingTemperatureTypeList(biome.temperatureType).add(biome.biome);
BOPBiomeHelper.getCorrespondingTemperatureTypeList(biome.temperatureType).add(biome);
}
public static void addSpawnBiome(BiomeGenBase biome)
@ -365,7 +365,7 @@ public class BOPBiomes
for (TemperatureType temperatureType : BOPBiomeHelper.TemperatureType.values())
{
BOPBiomeHelper.getCorrespondingTemperatureTypeList(temperatureType).clear();
addBiomeToList(new BOPBiomeListEntry(onlyBiome, temperatureType));
addBiomeToList(new BOPBiomeEntry(onlyBiome, temperatureType, 50));
}
}
}

View File

@ -1,19 +1,25 @@
package biomesoplenty.common.world;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.GenLayerBiome;
import net.minecraft.world.gen.layer.IntCache;
import biomesoplenty.api.BOPBiomeHelper.BOPBiomeEntry;
public class GenLayerBiomeBOP extends GenLayerBiome
{
public static ArrayList<BiomeGenBase> desertBiomes = new ArrayList();
public static ArrayList<BiomeGenBase> warmBiomes = new ArrayList();
public static ArrayList<BiomeGenBase> coldBiomes = new ArrayList();
public static ArrayList<BiomeGenBase> icyBiomes = new ArrayList();
public static List<BOPBiomeEntry> desertBiomes = new ArrayList<BOPBiomeEntry>();
public static List<BOPBiomeEntry> warmBiomes = new ArrayList<BOPBiomeEntry>();
public static List<BOPBiomeEntry> coldBiomes = new ArrayList<BOPBiomeEntry>();
public static List<BOPBiomeEntry> icyBiomes = new ArrayList<BOPBiomeEntry>();
public GenLayerBiomeBOP(long par1, GenLayer parentLayer, WorldType worldType)
{
@ -63,7 +69,7 @@ public class GenLayerBiomeBOP extends GenLayerBiome
}
else
{
aint1[j1 + i1 * par3] = this.desertBiomes.get(this.nextInt(this.desertBiomes.size())).biomeID;
aint1[j1 + i1 * par3] = getRandomBiome(desertBiomes).biome.biomeID;
}
}
else if (biomeID == 2)
@ -74,7 +80,7 @@ public class GenLayerBiomeBOP extends GenLayerBiome
}
else
{
aint1[j1 + i1 * par3] = this.warmBiomes.get(this.nextInt(this.warmBiomes.size())).biomeID;
aint1[j1 + i1 * par3] = getRandomBiome(warmBiomes).biome.biomeID;
}
}
else if (biomeID == 3)
@ -86,12 +92,12 @@ public class GenLayerBiomeBOP extends GenLayerBiome
}
else
{
aint1[j1 + i1 * par3] = this.coldBiomes.get(this.nextInt(this.coldBiomes.size())).biomeID;
aint1[j1 + i1 * par3] = getRandomBiome(coldBiomes).biome.biomeID;
}
}
else if (biomeID == 4)
{
aint1[j1 + i1 * par3] = this.icyBiomes.get(this.nextInt(this.icyBiomes.size())).biomeID;
aint1[j1 + i1 * par3] = getRandomBiome(icyBiomes).biome.biomeID;
}
else
{
@ -102,4 +108,37 @@ public class GenLayerBiomeBOP extends GenLayerBiome
return aint1;
}
public BOPBiomeEntry getRandomBiome(Collection weightedItems)
{
return getRandomBiome(weightedItems, WeightedRandom.getTotalWeight(weightedItems));
}
public BOPBiomeEntry getRandomBiome(Collection weightedItems, int totalWeight)
{
if (totalWeight <= 0)
{
throw new IllegalArgumentException();
}
else
{
int j = this.nextInt(totalWeight);
Iterator iterator = weightedItems.iterator();
BOPBiomeEntry item;
do
{
if (!iterator.hasNext())
{
return null;
}
item = (BOPBiomeEntry)iterator.next();
j -= item.itemWeight;
}
while (j >= 0);
return item;
}
}
}