diff --git a/src/main/java/net/minecraftforge/common/BiomeDictionary.java b/src/main/java/net/minecraftforge/common/BiomeDictionary.java index df4cf2e6a5..704137a531 100644 --- a/src/main/java/net/minecraftforge/common/BiomeDictionary.java +++ b/src/main/java/net/minecraftforge/common/BiomeDictionary.java @@ -4,10 +4,11 @@ import java.util.*; import net.minecraftforge.fml.common.FMLLog; import net.minecraft.init.Blocks; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.*; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.terraingen.DeferredBiomeDecorator; -import static net.minecraft.world.biome.BiomeGenBase.*; +import static net.minecraft.init.Biomes.*; import static net.minecraftforge.common.BiomeDictionary.Type.*; public class BiomeDictionary @@ -53,15 +54,7 @@ public class BiomeDictionary SANDY, SNOWY, WASTELAND, - BEACH, - - /*Deprecated tags, kept for compatibility*/ - @Deprecated - /**Replaced by SANDY**/ - DESERT(SANDY), - @Deprecated - /**Replaced by SNOWY**/ - FROZEN(SNOWY); + BEACH; private List subTags; @@ -106,7 +99,7 @@ public class BiomeDictionary { typeInfoList = Arrays.copyOf(typeInfoList, ret.ordinal()+1); } - for(BiomeInfo bInfo:biomeList) + for(BiomeInfo bInfo:biomeInfoMap.values()) { if(bInfo != null) { @@ -119,8 +112,7 @@ public class BiomeDictionary } } - private static final int BIOME_LIST_SIZE = BiomeGenBase.getBiomeGenArray().length; - private static BiomeInfo[] biomeList = new BiomeInfo[BIOME_LIST_SIZE]; + private static HashMap biomeInfoMap = new HashMap(); @SuppressWarnings("unchecked") private static ArrayList[] typeInfoList = new ArrayList[Type.values().length]; @@ -154,7 +146,7 @@ public class BiomeDictionary { types = listSubTags(types); - if(BiomeGenBase.getBiomeGenArray()[biome.biomeID] != null) + if(BiomeGenBase.field_185377_q.getNameForObject(biome) != null) { for(Type type : types) { @@ -166,15 +158,16 @@ public class BiomeDictionary typeInfoList[type.ordinal()].add(biome); } - if(biomeList[biome.biomeID] == null) + if(!isBiomeRegistered(biome)) { - biomeList[biome.biomeID] = new BiomeInfo(types); + ResourceLocation location = BiomeGenBase.field_185377_q.getNameForObject(biome); + biomeInfoMap.put(location, new BiomeInfo(types)); } else { for(Type type : types) { - biomeList[biome.biomeID].typeList.add(type); + getBiomeInfo(biome).typeList.add(type); } } @@ -208,14 +201,8 @@ public class BiomeDictionary */ public static Type[] getTypesForBiome(BiomeGenBase biome) { - checkRegistration(biome); - - if(biomeList[biome.biomeID] != null) - { - return (Type[])biomeList[biome.biomeID].typeList.toArray(new Type[0]); - } - - return new Type[0]; + checkRegistration(biome); + return (Type[])getBiomeInfo(biome).typeList.toArray(new Type[0]); } /** @@ -227,21 +214,15 @@ public class BiomeDictionary */ public static boolean areBiomesEquivalent(BiomeGenBase biomeA, BiomeGenBase biomeB) { - int a = biomeA.biomeID; - int b = biomeB.biomeID; - checkRegistration(biomeA); checkRegistration(biomeB); - if(biomeList[a] != null && biomeList[b] != null) + for(Type type : getTypesForBiome(biomeA)) { - for(Type type : biomeList[a].typeList) - { - if(containsType(biomeList[b], type)) - { - return true; - } - } + if(containsType(getBiomeInfo(biomeB), type)) + { + return true; + } } return false; @@ -257,13 +238,7 @@ public class BiomeDictionary public static boolean isBiomeOfType(BiomeGenBase biome, Type type) { checkRegistration(biome); - - if(biomeList[biome.biomeID] != null) - { - return containsType(biomeList[biome.biomeID], type); - } - - return false; + return containsType(getBiomeInfo(biome), type); } /** @@ -273,12 +248,7 @@ public class BiomeDictionary */ public static boolean isBiomeRegistered(BiomeGenBase biome) { - return biomeList[biome.biomeID] != null; - } - - public static boolean isBiomeRegistered(int biomeID) - { - return biomeList[biomeID] != null; + return biomeInfoMap.containsKey(BiomeGenBase.field_185377_q.getNameForObject(biome)); } public static void registerAllBiomes() @@ -294,15 +264,10 @@ public class BiomeDictionary */ public static void registerAllBiomesAndGenerateEvents() { - for(int i = 0; i < BiomeGenBase.getBiomeGenArray().length; i++) - { - BiomeGenBase biome = BiomeGenBase.getBiomeGenArray()[i]; - - if(biome == null) - { - continue; - } - + for (ResourceLocation biomeResource : BiomeGenBase.field_185377_q.getKeys()) + { + BiomeGenBase biome = BiomeGenBase.field_185377_q.getObject(biomeResource); + if (biome.theBiomeDecorator instanceof DeferredBiomeDecorator) { DeferredBiomeDecorator decorator = (DeferredBiomeDecorator) biome.theBiomeDecorator; @@ -324,7 +289,7 @@ public class BiomeDictionary { if (biome.theBiomeDecorator.treesPerChunk >= 3) { - if (biome.isHighHumidity() && biome.temperature >= 0.9F) + if (biome.isHighHumidity() && biome.func_185353_n() >= 0.9F) { BiomeDictionary.registerBiomeType(biome, JUNGLE); } @@ -332,36 +297,36 @@ public class BiomeDictionary { BiomeDictionary.registerBiomeType(biome, FOREST); - if (biome.temperature <= 0.2f) + if (biome.func_185353_n() <= 0.2f) { BiomeDictionary.registerBiomeType(biome, CONIFEROUS); } } } - else if(biome.maxHeight <= 0.3F && biome.maxHeight >= 0.0F) + else if(biome.func_185360_m() <= 0.3F && biome.func_185360_m() >= 0.0F) { - if(!biome.isHighHumidity() || biome.minHeight >= 0.0F) + if(!biome.isHighHumidity() || biome.func_185355_j() >= 0.0F) { BiomeDictionary.registerBiomeType(biome, PLAINS); } } - if (biome.rainfall > 0.85f) + if (biome.getFloatRainfall() > 0.85f) { BiomeDictionary.registerBiomeType(biome, WET); } - if (biome.rainfall < 0.15f) + if (biome.getFloatRainfall() < 0.15f) { BiomeDictionary.registerBiomeType(biome, DRY); } - if (biome.temperature > 0.85f) + if (biome.func_185353_n() > 0.85f) { BiomeDictionary.registerBiomeType(biome, HOT); } - if (biome.temperature < 0.15f) + if (biome.func_185353_n() < 0.15f) { BiomeDictionary.registerBiomeType(biome, COLD); } @@ -375,14 +340,14 @@ public class BiomeDictionary BiomeDictionary.registerBiomeType(biome, DENSE); } - if (biome.isHighHumidity() && biome.minHeight < 0.0F && (biome.maxHeight <= 0.3F && biome.maxHeight >= 0.0F)) + if (biome.isHighHumidity() && biome.func_185355_j() < 0.0F && (biome.func_185360_m() <= 0.3F && biome.func_185360_m() >= 0.0F)) { BiomeDictionary.registerBiomeType(biome, SWAMP); } - if (biome.minHeight <= -0.5F) + if (biome.func_185355_j() <= -0.5F) { - if (biome.maxHeight == 0.0F) + if (biome.func_185360_m() == 0.0F) { BiomeDictionary.registerBiomeType(biome, RIVER); } @@ -392,12 +357,12 @@ public class BiomeDictionary } } - if (biome.maxHeight >= 0.4F && biome.maxHeight < 1.5F) + if (biome.func_185360_m() >= 0.4F && biome.func_185360_m() < 1.5F) { BiomeDictionary.registerBiomeType(biome, HILLS); } - if (biome.maxHeight >= 1.5F) + if (biome.func_185360_m() >= 1.5F) { BiomeDictionary.registerBiomeType(biome, MOUNTAIN); } @@ -407,7 +372,7 @@ public class BiomeDictionary BiomeDictionary.registerBiomeType(biome, SNOWY); } - if (biome.topBlock != Blocks.sand && biome.temperature >= 1.0f && biome.rainfall < 0.2f) + if (biome.topBlock != Blocks.sand && biome.func_185353_n() >= 1.0f && biome.getFloatRainfall() < 0.2f) { BiomeDictionary.registerBiomeType(biome, SAVANNA); } @@ -427,6 +392,11 @@ public class BiomeDictionary } //Internal implementation + private static BiomeInfo getBiomeInfo(BiomeGenBase biome) + { + return biomeInfoMap.get(BiomeGenBase.field_185377_q.getNameForObject(biome)); + } + private static void checkRegistration(BiomeGenBase biome) { if(!isBiomeRegistered(biome))