Enhanced the Biome Dictionary with tags based on temperature, vegetation, moisture, trees and others
This commit is contained in:
parent
6db5d2ed26
commit
8d2ebdf25f
1 changed files with 191 additions and 61 deletions
|
@ -3,6 +3,7 @@ package net.minecraftforge.common;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.world.biome.*;
|
import net.minecraft.world.biome.*;
|
||||||
import net.minecraftforge.event.terraingen.DeferredBiomeDecorator;
|
import net.minecraftforge.event.terraingen.DeferredBiomeDecorator;
|
||||||
import static net.minecraft.world.biome.BiomeGenBase.*;
|
import static net.minecraft.world.biome.BiomeGenBase.*;
|
||||||
|
@ -12,21 +13,66 @@ public class BiomeDictionary
|
||||||
{
|
{
|
||||||
public enum Type
|
public enum Type
|
||||||
{
|
{
|
||||||
|
/*Temperature-based tags. Specifying neither implies a biome is temperate*/
|
||||||
|
HOT,
|
||||||
|
COLD,
|
||||||
|
/*Tags specifying the amount of vegetation a biome has. Specifying neither implies a biome to have moderate amounts*/
|
||||||
|
SPARSE,
|
||||||
|
DENSE,
|
||||||
|
/*Tags specifying how moist a biome is. Specifying neither implies the biome as having moderate humidity*/
|
||||||
|
WET,
|
||||||
|
DRY,
|
||||||
|
/*Tree-based tags, SAVANNA refers to dry, desert-like trees (Such as Acacia), CONIFEROUS refers to snowy trees (Such as Spruce) and JUNGLE refers to jungle trees.
|
||||||
|
* Specifying no tag implies a biome has temperate trees (Such as Oak)*/
|
||||||
|
SAVANNA,
|
||||||
|
CONIFEROUS,
|
||||||
|
JUNGLE,
|
||||||
|
|
||||||
|
/*Tags specifying the nature of a biome*/
|
||||||
|
SPOOKY,
|
||||||
|
DEAD,
|
||||||
|
LUSH,
|
||||||
|
NETHER,
|
||||||
|
END,
|
||||||
|
MUSHROOM,
|
||||||
|
MAGICAL,
|
||||||
|
|
||||||
|
OCEAN,
|
||||||
|
RIVER,
|
||||||
|
/**A general tag for all water-based biomes. Shown as present if OCEAN or RIVER are.**/
|
||||||
|
WATER(OCEAN, RIVER),
|
||||||
|
|
||||||
|
/*Generic types which a biome can be*/
|
||||||
|
MESA,
|
||||||
FOREST,
|
FOREST,
|
||||||
PLAINS,
|
PLAINS,
|
||||||
MOUNTAIN,
|
MOUNTAIN,
|
||||||
HILLS,
|
HILLS,
|
||||||
SWAMP,
|
SWAMP,
|
||||||
WATER,
|
SANDY,
|
||||||
DESERT,
|
SNOWY,
|
||||||
FROZEN,
|
|
||||||
JUNGLE,
|
|
||||||
WASTELAND,
|
WASTELAND,
|
||||||
BEACH,
|
BEACH,
|
||||||
NETHER,
|
|
||||||
END,
|
/*Deprecated tags, kept for compatibility*/
|
||||||
MUSHROOM,
|
@Deprecated
|
||||||
MAGICAL;
|
/**Replaced by SANDY**/
|
||||||
|
DESERT(SANDY),
|
||||||
|
@Deprecated
|
||||||
|
/**Replaced by SNOWY**/
|
||||||
|
FROZEN(SNOWY);
|
||||||
|
|
||||||
|
private List<Type> subTags;
|
||||||
|
|
||||||
|
private Type(Type... subTags)
|
||||||
|
{
|
||||||
|
this.subTags = Arrays.asList(subTags);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasSubTags()
|
||||||
|
{
|
||||||
|
return subTags != null && !subTags.isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int BIOME_LIST_SIZE = BiomeGenBase.getBiomeGenArray().length;
|
private static final int BIOME_LIST_SIZE = BiomeGenBase.getBiomeGenArray().length;
|
||||||
|
@ -62,6 +108,8 @@ public class BiomeDictionary
|
||||||
*/
|
*/
|
||||||
public static boolean registerBiomeType(BiomeGenBase biome, Type ... types)
|
public static boolean registerBiomeType(BiomeGenBase biome, Type ... types)
|
||||||
{
|
{
|
||||||
|
types = listSubTags(types);
|
||||||
|
|
||||||
if(BiomeGenBase.getBiomeGenArray()[biome.biomeID] != null)
|
if(BiomeGenBase.getBiomeGenArray()[biome.biomeID] != null)
|
||||||
{
|
{
|
||||||
for(Type type : types)
|
for(Type type : types)
|
||||||
|
@ -232,15 +280,20 @@ public class BiomeDictionary
|
||||||
*/
|
*/
|
||||||
public static void makeBestGuess(BiomeGenBase biome)
|
public static void makeBestGuess(BiomeGenBase biome)
|
||||||
{
|
{
|
||||||
if(biome.theBiomeDecorator.treesPerChunk >= 3)
|
if (biome.theBiomeDecorator.treesPerChunk >= 3)
|
||||||
{
|
{
|
||||||
if(biome.isHighHumidity() && biome.temperature >= 1.0F)
|
if (biome.isHighHumidity() && biome.temperature >= 0.9F)
|
||||||
{
|
{
|
||||||
BiomeDictionary.registerBiomeType(biome, JUNGLE);
|
BiomeDictionary.registerBiomeType(biome, JUNGLE);
|
||||||
}
|
}
|
||||||
else if(!biome.isHighHumidity())
|
else if (!biome.isHighHumidity())
|
||||||
{
|
{
|
||||||
BiomeDictionary.registerBiomeType(biome, FOREST);
|
BiomeDictionary.registerBiomeType(biome, FOREST);
|
||||||
|
|
||||||
|
if (biome.temperature <= 0.2f)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, CONIFEROUS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(biome.heightVariation <= 0.3F && biome.heightVariation >= 0.0F)
|
else if(biome.heightVariation <= 0.3F && biome.heightVariation >= 0.0F)
|
||||||
|
@ -251,29 +304,83 @@ public class BiomeDictionary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(biome.isHighHumidity() && biome.rootHeight < 0.0F && (biome.heightVariation <= 0.3F && biome.heightVariation >= 0.0F))
|
if (biome.rainfall > 0.85f)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, WET);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biome.rainfall < 0.15f)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, DRY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biome.temperature > 0.85f)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, HOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biome.temperature < 0.15f)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, COLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biome.theBiomeDecorator.treesPerChunk > 0 && biome.theBiomeDecorator.treesPerChunk < 3)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, SPARSE);
|
||||||
|
}
|
||||||
|
else if (biome.theBiomeDecorator.treesPerChunk >= 10)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, DENSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biome.isHighHumidity() && biome.rootHeight < 0.0F && (biome.heightVariation <= 0.3F && biome.heightVariation >= 0.0F))
|
||||||
{
|
{
|
||||||
BiomeDictionary.registerBiomeType(biome, SWAMP);
|
BiomeDictionary.registerBiomeType(biome, SWAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(biome.rootHeight <= -0.5F)
|
if (biome.rootHeight <= -0.5F)
|
||||||
{
|
{
|
||||||
BiomeDictionary.registerBiomeType(biome, WATER);
|
if (biome.heightVariation == 0.0F)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, RIVER);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, OCEAN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(biome.heightVariation >= 1.5F)
|
if (biome.heightVariation >= 0.4F && biome.heightVariation < 1.5F)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, HILLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biome.heightVariation >= 1.5F)
|
||||||
{
|
{
|
||||||
BiomeDictionary.registerBiomeType(biome, MOUNTAIN);
|
BiomeDictionary.registerBiomeType(biome, MOUNTAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(biome.getEnableSnow() || biome.temperature < 0.2F)
|
if (biome.getEnableSnow())
|
||||||
{
|
{
|
||||||
BiomeDictionary.registerBiomeType(biome, FROZEN);
|
BiomeDictionary.registerBiomeType(biome, SNOWY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!biome.isHighHumidity() && biome.temperature >= 1.0F)
|
if (biome.topBlock != Blocks.sand && biome.temperature >= 1.0f && biome.rainfall < 0.2f)
|
||||||
{
|
{
|
||||||
BiomeDictionary.registerBiomeType(biome, DESERT);
|
BiomeDictionary.registerBiomeType(biome, SAVANNA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biome.topBlock == Blocks.sand )
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, SANDY);
|
||||||
|
}
|
||||||
|
else if (biome.topBlock == Blocks.hardened_clay)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, MESA);
|
||||||
|
}
|
||||||
|
else if (biome.topBlock == Blocks.mycelium)
|
||||||
|
{
|
||||||
|
BiomeDictionary.registerBiomeType(biome, MUSHROOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,50 +395,73 @@ public class BiomeDictionary
|
||||||
|
|
||||||
private static boolean containsType(BiomeInfo info, Type type)
|
private static boolean containsType(BiomeInfo info, Type type)
|
||||||
{
|
{
|
||||||
|
if (type.hasSubTags())
|
||||||
|
{
|
||||||
|
for (Type remappedType : listSubTags(type))
|
||||||
|
{
|
||||||
|
if (info.typeList.contains(remappedType)) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return info.typeList.contains(type);
|
return info.typeList.contains(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Type[] listSubTags(Type... types)
|
||||||
|
{
|
||||||
|
List<Type> subTags = new ArrayList<Type>();
|
||||||
|
|
||||||
|
for (Type type : types)
|
||||||
|
{
|
||||||
|
if (type.hasSubTags()) subTags.addAll(type.subTags);
|
||||||
|
else subTags.add(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return subTags.toArray(new Type[subTags.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
private static void registerVanillaBiomes()
|
private static void registerVanillaBiomes()
|
||||||
{
|
{
|
||||||
registerBiomeType(ocean, WATER );
|
registerBiomeType(ocean, OCEAN );
|
||||||
registerBiomeType(plains, PLAINS );
|
registerBiomeType(plains, PLAINS );
|
||||||
registerBiomeType(desert, DESERT );
|
registerBiomeType(desert, HOT, DRY, SANDY );
|
||||||
registerBiomeType(extremeHills, MOUNTAIN );
|
registerBiomeType(extremeHills, MOUNTAIN, HILLS );
|
||||||
registerBiomeType(forest, FOREST );
|
registerBiomeType(forest, FOREST );
|
||||||
registerBiomeType(taiga, FOREST, FROZEN);
|
registerBiomeType(taiga, COLD, CONIFEROUS, FOREST );
|
||||||
registerBiomeType(taigaHills, FOREST, FROZEN);
|
registerBiomeType(taigaHills, COLD, CONIFEROUS, FOREST, HILLS );
|
||||||
registerBiomeType(swampland, SWAMP );
|
registerBiomeType(swampland, WET, SWAMP );
|
||||||
registerBiomeType(river, WATER );
|
registerBiomeType(river, RIVER );
|
||||||
registerBiomeType(frozenOcean, WATER, FROZEN);
|
registerBiomeType(frozenOcean, COLD, OCEAN, SNOWY );
|
||||||
registerBiomeType(frozenRiver, WATER, FROZEN);
|
registerBiomeType(frozenRiver, COLD, RIVER, SNOWY );
|
||||||
registerBiomeType(icePlains, FROZEN );
|
registerBiomeType(icePlains, COLD, SNOWY, WASTELAND );
|
||||||
registerBiomeType(iceMountains, FROZEN );
|
registerBiomeType(iceMountains, COLD, SNOWY, MOUNTAIN );
|
||||||
registerBiomeType(beach, BEACH );
|
registerBiomeType(beach, BEACH );
|
||||||
registerBiomeType(desertHills, DESERT );
|
registerBiomeType(desertHills, HOT, DRY, SANDY, HILLS );
|
||||||
registerBiomeType(jungle, JUNGLE );
|
registerBiomeType(jungle, HOT, WET, DENSE, JUNGLE );
|
||||||
registerBiomeType(jungleHills, JUNGLE );
|
registerBiomeType(jungleHills, HOT, WET, DENSE, JUNGLE, HILLS);
|
||||||
registerBiomeType(forestHills, FOREST );
|
registerBiomeType(forestHills, FOREST, HILLS );
|
||||||
registerBiomeType(sky, END );
|
registerBiomeType(sky, COLD, DRY, END );
|
||||||
registerBiomeType(hell, NETHER );
|
registerBiomeType(hell, HOT, DRY, NETHER );
|
||||||
registerBiomeType(mushroomIsland, MUSHROOM );
|
registerBiomeType(mushroomIsland, MUSHROOM );
|
||||||
registerBiomeType(extremeHillsEdge, MOUNTAIN );
|
registerBiomeType(extremeHillsEdge, MOUNTAIN );
|
||||||
registerBiomeType(mushroomIslandShore, MUSHROOM, BEACH);
|
registerBiomeType(mushroomIslandShore, MUSHROOM, BEACH );
|
||||||
registerBiomeType(jungleEdge, JUNGLE );
|
registerBiomeType(jungleEdge, HOT, WET, JUNGLE, FOREST );
|
||||||
registerBiomeType(deepOcean, WATER );
|
registerBiomeType(deepOcean, OCEAN );
|
||||||
registerBiomeType(stoneBeach, BEACH );
|
registerBiomeType(stoneBeach, BEACH );
|
||||||
registerBiomeType(coldBeach, BEACH, FROZEN);
|
registerBiomeType(coldBeach, COLD, BEACH, SNOWY );
|
||||||
registerBiomeType(birchForest, FOREST );
|
registerBiomeType(birchForest, FOREST );
|
||||||
registerBiomeType(birchForestHills, FOREST );
|
registerBiomeType(birchForestHills, FOREST, HILLS );
|
||||||
registerBiomeType(roofedForest, FOREST );
|
registerBiomeType(roofedForest, SPOOKY, DENSE, FOREST );
|
||||||
registerBiomeType(coldTaiga, FOREST, FROZEN);
|
registerBiomeType(coldTaiga, COLD, CONIFEROUS, FOREST, SNOWY );
|
||||||
registerBiomeType(coldTaigaHills, FOREST, FROZEN);
|
registerBiomeType(coldTaigaHills, COLD, CONIFEROUS, FOREST, SNOWY, HILLS);
|
||||||
registerBiomeType(megaTaiga, FOREST );
|
registerBiomeType(megaTaiga, COLD, CONIFEROUS, FOREST );
|
||||||
registerBiomeType(megaTaigaHills, FOREST );
|
registerBiomeType(megaTaigaHills, COLD, CONIFEROUS, FOREST, HILLS );
|
||||||
registerBiomeType(extremeHillsPlus, FOREST );
|
registerBiomeType(extremeHillsPlus, MOUNTAIN, FOREST, SPARSE );
|
||||||
registerBiomeType(savanna, PLAINS, DESERT);
|
registerBiomeType(savanna, HOT, SAVANNA, PLAINS, SPARSE );
|
||||||
registerBiomeType(savannaPlateau, PLAINS, DESERT);
|
registerBiomeType(savannaPlateau, HOT, SAVANNA, PLAINS, SPARSE );
|
||||||
registerBiomeType(mesa, DESERT );
|
registerBiomeType(mesa, MESA, SANDY );
|
||||||
registerBiomeType(mesaPlateau_F, DESERT );
|
registerBiomeType(mesaPlateau_F, MESA, SPARSE, SANDY );
|
||||||
registerBiomeType(mesaPlateau, DESERT );
|
registerBiomeType(mesaPlateau, MESA, SANDY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue