From 6892234a5417ddea3aa02adc45fc70dbc4868947 Mon Sep 17 00:00:00 2001 From: Meepster Date: Thu, 24 Apr 2014 23:40:40 -0500 Subject: [PATCH 1/3] Changed Oil Generation to use config file ID's for generation to support integration with mods like Biomes O' Plenty --- common/buildcraft/BuildCraftEnergy.java | 15 ++++++++++++++- .../buildcraft/energy/worldgen/OilPopulate.java | 9 +++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index b5eab9b2..8c9c1025 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -9,7 +9,8 @@ package buildcraft; import java.util.TreeMap; - +import java.util.HashSet; +import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -81,6 +82,9 @@ public class BuildCraftEnergy extends BuildCraftMod { public static Item fuel; public static boolean canOilBurn; public static double oilWellScalar = 1.0; + public static Set oilBiomeIDs = new HashSet(); + public static Set excessiveOilBiomeIDs = new HashSet(); + public static Set excludeOilBiomeIDs = new HashSet(); public static TreeMap saturationStored = new TreeMap(); public static BCTrigger triggerBlueEngineHeat = new TriggerEngineHeat(EnergyStage.BLUE); public static BCTrigger triggerGreenEngineHeat = new TriggerEngineHeat(EnergyStage.GREEN); @@ -95,6 +99,15 @@ 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, "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, "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)); + } double fuelOilMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.oil.combustion", 1.0F, "adjust energy value of Oil in Combustion Engines").getDouble(1.0F); double fuelFuelMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.fuel.combustion", 1.0F, "adjust energy value of Fuel in Combustion Engines").getDouble(1.0F); diff --git a/common/buildcraft/energy/worldgen/OilPopulate.java b/common/buildcraft/energy/worldgen/OilPopulate.java index 0deec4f7..51896d9a 100644 --- a/common/buildcraft/energy/worldgen/OilPopulate.java +++ b/common/buildcraft/energy/worldgen/OilPopulate.java @@ -83,18 +83,15 @@ public class OilPopulate { BiomeGenBase biome = world.getBiomeGenForCoords(x, z); // Do not generate oil in the End or Nether - if (excludedBiomes.contains(biome.biomeID)) { + if (BuildCraftEnergy.excludeOilBiomeIDs.contains(biome.biomeID)) { return; } - boolean oilBiome = surfaceDepositBiomes.contains(biome.biomeID) - || BiomeDictionary.isBiomeOfType(biome, DESERT) - || (BiomeDictionary.isBiomeOfType(biome, WASTELAND) && !BiomeDictionary.isBiomeOfType(biome, FROZEN)) - || (BiomeDictionary.isBiomeOfType(biome, FOREST) && BiomeDictionary.isBiomeOfType(biome, FROZEN)); + boolean oilBiome = BuildCraftEnergy.oilBiomeIDs.contains(biome.biomeID); double bonus = oilBiome ? 3.0 : 1.0; bonus *= BuildCraftEnergy.oilWellScalar; - if (excessiveBiomes.contains(biome.biomeID)) { + if (BuildCraftEnergy.excessiveOilBiomeIDs.contains(biome.biomeID)) { bonus *= 30.0; } else if (BuildCraftCore.debugMode) { bonus *= 20.0; From a6fa40679306ec790d93e17cc99d6d78a46f431a Mon Sep 17 00:00:00 2001 From: Meepster Date: Fri, 25 Apr 2014 15:46:05 -0500 Subject: [PATCH 2/3] Enabled use of BiomeDictionary.Type to pass in addition to IDs of biomes. Added error handling. Doesn't seem to print the warning to the log correctly though, just prints a string as info it looks. --- common/buildcraft/BuildCraftEnergy.java | 52 ++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) 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); From 1a1bb18a7a490f123ae640fd835f41d371b64c8d Mon Sep 17 00:00:00 2001 From: Meepster Date: Fri, 25 Apr 2014 16:02:53 -0500 Subject: [PATCH 3/3] Forgot to trim ids.. Oops.. --- common/buildcraft/BuildCraftEnergy.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index d478e73f..ffff0c0b 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -104,6 +104,7 @@ public class BuildCraftEnergy extends BuildCraftMod { 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", 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(",")){ + id = id.trim(); 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 @@ -119,6 +120,7 @@ public class BuildCraftEnergy extends BuildCraftMod { } } 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(",")) { + id = id.trim(); 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 @@ -134,6 +136,7 @@ public class BuildCraftEnergy extends BuildCraftMod { } } 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(",")){ + id = id.trim(); 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