diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 8c9c1025..d478e73f 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -11,6 +11,8 @@ package buildcraft; import java.util.TreeMap; import java.util.HashSet; import java.util.Set; +import java.util.logging.Level; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -19,6 +21,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fluids.Fluid; @@ -35,6 +38,7 @@ import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.triggers.BCTrigger; +import buildcraft.core.utils.BCLog; import buildcraft.energy.BlockBuildcraftFluid; import buildcraft.energy.BlockEngine; import buildcraft.energy.BucketHandler; @@ -99,14 +103,50 @@ public class BuildCraftEnergy extends BuildCraftMod { int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN); canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true); oilWellScalar = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilWellGenerationRate", 1.0, "Probability of oil well generation").getDouble(1.0); - for(String id : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilBiomeIDs", BiomeGenBase.desert.biomeID +","+BiomeGenBase.taiga.biomeID, "ID's of biomes that should have increased oil generation rates.").getString().trim().split(",")){ - if(id.length() > 0) oilBiomeIDs.add(Integer.parseInt(id)); + for (String id : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilBiomeIDs", BiomeDictionary.Type.DESERT.toString() +","+BiomeGenBase.taiga.biomeID, "IDs or Biome Types (e.g. DESERT,OCEAN) of biomes that should have increased oil generation rates.").getString().trim().split(",")){ + if(id.length() > 0){ + try{oilBiomeIDs.add(Integer.parseInt(id));} + catch(NumberFormatException ex){ //not an int so try and parse it as a biome type + try{ + for (BiomeGenBase b : BiomeDictionary.getBiomesForType(BiomeDictionary.Type.valueOf(id.toUpperCase()))){ + oilBiomeIDs.add(b.biomeID); + } + } + catch (Exception e){ + BCLog.logger.log(Level.WARNING,"config.oilBiomeIDs: Could not find biome type: " + id + " ; Skipping!"); + } + } + } } - for(String id : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "excessiveOilBiomeIDs", "", "ID's of biomes that should have GREATLY increased oil generation rates.").getString().trim().split(",")) { - if(id.length() > 0) excessiveOilBiomeIDs.add(Integer.parseInt(id)); + for(String id : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "excessiveOilBiomeIDs", "", "IDs or Biome Types (e.g. DESERT,OCEAN) of biomes that should have GREATLY increased oil generation rates.").getString().trim().split(",")) { + if(id.length() > 0){ + try{excessiveOilBiomeIDs.add(Integer.parseInt(id));} + catch(NumberFormatException ex){ //not an int so try and parse it as a biome type + try{ + for (BiomeGenBase b : BiomeDictionary.getBiomesForType(BiomeDictionary.Type.valueOf(id.toUpperCase()))){ + excessiveOilBiomeIDs.add(b.biomeID); + } + } + catch (Exception e){ + BCLog.logger.log(Level.WARNING,"config.excessiveOilBiomeIDs: Could not find biome type: " + id + " ; Skipping!"); + } + } + } } - for(String id : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "excludeOilBiomeIDs", BiomeGenBase.sky.biomeID +","+BiomeGenBase.hell.biomeID, "ID's of biomes that are excluded from generating oil.").getString().trim().split(",")){ - if(id.length() > 0) excludeOilBiomeIDs.add(Integer.parseInt(id)); + for(String id : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "excludeOilBiomeIDs", BiomeGenBase.sky.biomeID +","+BiomeGenBase.hell.biomeID, "IDs or Biome Types (e.g. DESERT,OCEAN) of biomes that are excluded from generating oil.").getString().trim().split(",")){ + if(id.length() > 0){ + try{excludeOilBiomeIDs.add(Integer.parseInt(id));} + catch(NumberFormatException ex){ //not an int so try and parse it as a biome type + try{ + for (BiomeGenBase b : BiomeDictionary.getBiomesForType(BiomeDictionary.Type.valueOf(id.toUpperCase()))){ + excludeOilBiomeIDs.add(b.biomeID); + } + } + catch (Exception e){ + BCLog.logger.log(Level.WARNING,"config.excludeOilBiomeIDs: Could not find biome type: " + id + " ; Skipping!"); + } + } + } } double fuelOilMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.oil.combustion", 1.0F, "adjust energy value of Oil in Combustion Engines").getDouble(1.0F);