From 772ec04bf33679baed10c72991336b5b648603bb Mon Sep 17 00:00:00 2001 From: Maxime Legkiy Date: Thu, 9 Feb 2017 05:38:20 +0300 Subject: [PATCH] Add Underground Oil Generating settings in GregTech.cfg Add supports White and Black List (DIM ID) Add settings generating for standart Dimension and Galacticraft Dimension - Moon and Mars Add settings for select type Underground Fluid - for Nether default Pahoehoe Lava, for Moon - Helium 3 Add settings max Amount Generating For generating oil in other Dimension (Twilight Forest or Mystcraft) use settings - RealDimensionEnable --- src/main/java/gregtech/GT_Mod.java | 17 +++++- .../java/gregtech/api/util/GT_Utility.java | 55 +++++++++++++++---- src/main/java/gregtech/common/GT_Proxy.java | 15 ++++- 3 files changed, 70 insertions(+), 17 deletions(-) diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 43cf7d6b..d551d64b 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -251,9 +251,20 @@ public class GT_Mod implements IGT_Mod { gregtechproxy.mPollutionPoisonLimit = tMainConfig.get("Pollution", "PoisonLimit", 750000).getInt(750000); gregtechproxy.mPollutionVegetationLimit = tMainConfig.get("Pollution", "VegetationLimit", 1000000).getInt(1000000); gregtechproxy.mPollutionSourRainLimit = tMainConfig.get("Pollution", "SourRainLimit", 2000000).getInt(2000000); - gregtechproxy.mUndergroundOilOverworld = tMainConfig.get("UndergroundOil", "EnableOverworld", true).getBoolean(true); - gregtechproxy.mUndergroundOilInRealDimension = tMainConfig.get("UndergroundOil", "EnableInRealDimension", true).getBoolean(true); - gregtechproxy.mUndergroundOilMaxAmount = tMainConfig.get("UndergroundOil", "MaxAmount", 50).getInt(50); + gregtechproxy.mUndergroundOilOverworld = tMainConfig.get("UndergroundOil", "OverworldEnable", true, "Generate Underground Oil on Overworld").getBoolean(true); + gregtechproxy.mUndergroundOilInRealDimension = tMainConfig.get("UndergroundOil", "RealDimensionEnable", true, "Generate Underground Oil on other world (not another Planet)").getBoolean(true); + gregtechproxy.mUndergroundOilNether = tMainConfig.get("UndergroundOil", "NetherEnable", true, "Generate Underground Oil on Nether").getBoolean(true); + gregtechproxy.mUndergroundOilMoon = tMainConfig.get("UndergroundOil", "MoonEnable", true, "Generate Underground Oil on Moon").getBoolean(true); + gregtechproxy.mUndergroundOilMars = tMainConfig.get("UndergroundOil", "MarsEnable", false, "Generate Underground Oil on Mars").getBoolean(false); + gregtechproxy.mUndergroundOilMaxAmount = tMainConfig.get("UndergroundOil", "OverworldMaxAmount", 625, "Max amount on Overworld").getInt(625); + gregtechproxy.mUndergroundOilNetherMaxAmount = tMainConfig.get("UndergroundOil", "NetherMaxAmount", 625, "Max amount on Nether").getInt(625); + gregtechproxy.mUndergroundOilMoonMaxAmount = tMainConfig.get("UndergroundOil", "MoonMaxAmount", 625, "Max amount on Moon").getInt(625); + gregtechproxy.mUndergroundOilNetherResType = tMainConfig.get("UndergroundOil", "NetherResType", 1, "Type of the generated resource on Nether (0 - Oil, 1 - Basalt Lava, 2- He3)", 0, 2).getInt(1); + gregtechproxy.mUndergroundOilMoonResType = tMainConfig.get("UndergroundOil", "MoonResType", 2, "Type of the generated resource on Moon (0 - Oil, 1 - Basalt Lava, 2- He3)", 0, 2).getInt(2); + gregtechproxy.mUndergroundOilBlackList = tMainConfig.get("UndergroundOil", "DimBlackList", new int[0], "Dimension IDs Black List").getIntList(); + java.util.Arrays.sort(gregtechproxy.mUndergroundOilBlackList); + gregtechproxy.mUndergroundOilWhiteList = tMainConfig.get("UndergroundOil", "DimWhiteList", new int[0], "Dimension IDs White List").getIntList(); + java.util.Arrays.sort(gregtechproxy.mUndergroundOilWhiteList); gregtechproxy.mExplosionItemDrop = tMainConfig.get("general", "ExplosionItemDrops", false).getBoolean(false); gregtechproxy.mAddGTRecipesToIC2Machines = tMainConfig.get("general", "AddGTRecipesToIC2Machines", true).getBoolean(true); diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 0bc98d45..ade00001 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1523,19 +1523,36 @@ public class GT_Utility { return (int)Math.floor(aValue / aScale); } - public static boolean getUndergroundOilSpawns(int aDimensionId) { + public static boolean getUndergroundOilGenerating(int aDimensionId) { - //Black list - if (DimensionManager.getProvider(aDimensionId).getClass().getName().contains("net.minecraft.world.WorldProviderHell")) return false; - if (DimensionManager.getProvider(aDimensionId).getClass().getName().contains("net.minecraft.world.WorldProviderEnd")) return false; - //Use settings - if (GT_Mod.gregtechproxy.mUndergroundOilOverworld && aDimensionId==0) return true; //Overworld - if (GT_Mod.gregtechproxy.mUndergroundOilInRealDimension && isRealDimension(aDimensionId)) return true; //Other real world + if (java.util.Arrays.binarySearch(GT_Mod.gregtechproxy.mUndergroundOilBlackList, aDimensionId) >= 0) return false; //Use BlackList Settings + if (java.util.Arrays.binarySearch(GT_Mod.gregtechproxy.mUndergroundOilWhiteList, aDimensionId) >= 0) return true; //Use WhiteList Settings + if (aDimensionId == 1) return false; //No bedrock, no oil. End. + if (aDimensionId==0) return GT_Mod.gregtechproxy.mUndergroundOilOverworld; //Overworld + if (aDimensionId == -1) return GT_Mod.gregtechproxy.mUndergroundOilNether; //Nether + + if (DimensionManager.getProvider(aDimensionId).getClass().getName().contains("Moon")) return GT_Mod.gregtechproxy.mUndergroundOilMoon; //Moon + if (DimensionManager.getProvider(aDimensionId).getClass().getName().contains("Mars")) return GT_Mod.gregtechproxy.mUndergroundOilMars; //Mars - return false; //If other planets... + if (isRealDimension(aDimensionId)) return GT_Mod.gregtechproxy.mUndergroundOilInRealDimension; //Other real world + + return false; //If other planets or worlds... } + + public static int getUndergroundOilType(int aType, int aOil) { + switch (aType) { + case 1: + aOil = 10; + break; + case 2: + aOil = 11; + break; + } + return aOil; + } + public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) { return getUndergroundOil(aWorld, aX, aZ, false); @@ -1543,15 +1560,25 @@ public class GT_Utility { public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ, boolean needConsumeOil) { - if (!getUndergroundOilSpawns(aWorld.provider.dimensionId)) + if (!getUndergroundOilGenerating(aWorld.provider.dimensionId)) return null; Random tRandom = new Random((aWorld.getSeed() + aWorld.provider.dimensionId * 2 + (getScaleСoordinates(aX,96)) + (7 * (getScaleСoordinates(aZ,96))))); int oil = tRandom.nextInt(3); - double amount = tRandom.nextInt(GT_Mod.gregtechproxy.mUndergroundOilMaxAmount) + tRandom.nextDouble(); oil = tRandom.nextInt(4); + int maxAmount; + if (aWorld.provider.dimensionId == -1){ + maxAmount = GT_Mod.gregtechproxy.mUndergroundOilNetherMaxAmount; + oil=getUndergroundOilType(GT_Mod.gregtechproxy.mUndergroundOilNetherResType,oil); + } else if (DimensionManager.getProvider(aWorld.provider.dimensionId).getClass().getName().contains("Moon")){ + maxAmount = GT_Mod.gregtechproxy.mUndergroundOilMoonMaxAmount; + oil=getUndergroundOilType(GT_Mod.gregtechproxy.mUndergroundOilMoonResType,oil); + } + else maxAmount = GT_Mod.gregtechproxy.mUndergroundOilMaxAmount; + + maxAmount = (int)Math.round(Math.pow(maxAmount*500000.d, 0.2)); + double amount = tRandom.nextInt(maxAmount) + tRandom.nextDouble(); // System.out.println("Oil: "+(getScaleСoordinates(aX,96))+" "+(getScaleСoordinates(aX,96))+" "+oil+" "+amount); -// amount = 40; Fluid tFluid = null; switch (oil) { case 0: @@ -1566,6 +1593,12 @@ public class GT_Utility { case 3: tFluid = Materials.OilHeavy.mFluid; break; + case 10: + tFluid = FluidRegistry.getFluid("ic2pahoehoelava"); + break; + case 11: + tFluid = Materials.Helium_3.mGas; + break; default: tFluid = Materials.Oil.mFluid; } diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 1680fb50..7fcdd1ad 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -165,8 +165,11 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public boolean mHideUnusedOres = true; public boolean mHideRecyclingRecipes = true; public boolean mPollution = true; - public boolean mUndergroundOilOverworld = true; - public boolean mUndergroundOilInRealDimension = true; + public boolean mUndergroundOilOverworld = true; //in DIM 0 + public boolean mUndergroundOilInRealDimension = true; //in other + public boolean mUndergroundOilNether = true; //in DIM -1 + public boolean mUndergroundOilMoon = true; //in Galacticraft Moon + public boolean mUndergroundOilMars = false; //in Galacticraft Mars public boolean mExplosionItemDrop = false; public int mSkeletonsShootGTArrows = 16; public int mMaxEqualEntitiesAtOneSpot = 3; @@ -181,8 +184,14 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public int mPollutionPoisonLimit = 750000; public int mPollutionVegetationLimit = 1000000; public int mPollutionSourRainLimit = 2000000; - public int mUndergroundOilMaxAmount = 50; + public int mUndergroundOilMaxAmount = 625; //mb in step + public int mUndergroundOilNetherMaxAmount = 625; //mb in step + public int mUndergroundOilNetherResType = 1; //0 - Oil; 1 - basalt lava; 3 - He3 + public int mUndergroundOilMoonMaxAmount = 625; //mb in step + public int mUndergroundOilMoonResType = 2; //0 - Oil; 1 - basalt lava; 3 - He3 public int mTicksUntilNextCraftSound = 0; + public int[] mUndergroundOilBlackList; + public int[] mUndergroundOilWhiteList; public double mMagneticraftBonusOutputPercent = 100.0d; private World mUniverse = null; private final String aTextThermalExpansion = "ThermalExpansion";