diff options
author | Blood-Asp <bloodasphendrik@gmail.com> | 2017-02-28 01:55:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-28 01:55:31 +0100 |
commit | 476146cd394a583e8d6872482b93bb9ad83612b0 (patch) | |
tree | ccde7e77754c534a54fcbdcba81d1fb4e158fbde | |
parent | 64ddbfef6e92274c65b50bd15019240f110caad8 (diff) | |
parent | 8e2280bc2c700a04ae5b829fe79eba4ba95a22d3 (diff) | |
download | GT5-Unofficial-476146cd394a583e8d6872482b93bb9ad83612b0.tar.gz GT5-Unofficial-476146cd394a583e8d6872482b93bb9ad83612b0.tar.bz2 GT5-Unofficial-476146cd394a583e8d6872482b93bb9ad83612b0.zip |
Merge pull request #890 from maixgame/unstable
Fix bug > Oil Teleportation to GC Planets #837
17 files changed, 319 insertions, 98 deletions
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index ef271204ec..ef0635bc2d 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -253,6 +253,7 @@ public class GT_Mod implements IGT_Mod { gregtechproxy.mPollutionSourRainLimit = tMainConfig.get("Pollution", "SourRainLimit", 2000000).getInt(2000000);
gregtechproxy.mExplosionItemDrop = tMainConfig.get("general", "ExplosionItemDrops", false).getBoolean(false);
gregtechproxy.mAddGTRecipesToIC2Machines = tMainConfig.get("general", "AddGTRecipesToIC2Machines", true).getBoolean(true);
+ gregtechproxy.mUndergroundOil.getConfig(tMainConfig, "undergroundfluid");
GregTech_API.mOutputRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "OutputRF", true);
GregTech_API.mInputRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "InputRF", false);
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 3b2f37085a..4aa49a954c 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -1146,7 +1146,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } } } - GT_Pollution.addPollution(new ChunkPosition(getXCoord(), getYCoord(), getZCoord()), 100000); + GT_Pollution.addPollution(getWorld(), new ChunkPosition(getXCoord(), getYCoord(), getZCoord()), 100000); mMetaTileEntity.doExplosion(aAmount); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index 751a33e255..bd5b8d9ea6 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -210,7 +210,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } } if(tProducedEU>0&&getPollution()>0){ - GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), + GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), (int) ((tProducedEU * getPollution()/(500*mTier))+1)); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java index 319b549d38..7246a58c26 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java @@ -61,7 +61,7 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { public boolean polluteEnvironment() { if(getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing())){ - GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), calculatePollutionReduction(10000)); + GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), calculatePollutionReduction(10000)); return true; } return false; diff --git a/src/main/java/gregtech/api/objects/GT_UO_Dimension.java b/src/main/java/gregtech/api/objects/GT_UO_Dimension.java new file mode 100644 index 0000000000..ffad72868c --- /dev/null +++ b/src/main/java/gregtech/api/objects/GT_UO_Dimension.java @@ -0,0 +1,52 @@ +package gregtech.api.objects; + +import java.util.ArrayList; +import java.util.Random; +import java.util.Set; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +import gregtech.api.enums.GT_Values; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fluids.Fluid; + +public class GT_UO_Dimension { + + private BiMap<String, GT_UO_Fluid> fFluids; + private int maxChance; + public String Dimension = "null"; + + public GT_UO_Dimension(ConfigCategory aConfigCategory) { + fFluids = HashBiMap.create(); + if (aConfigCategory.containsKey("Dimension")) + { + aConfigCategory.get("Dimension").comment = "Dimension ID or Class Name"; + Dimension = aConfigCategory.get("Dimension").getString(); + } + maxChance = 0; + //System.out.println("GT UO "+aConfigCategory.getName()+" Dimension:"+Dimension); + for (int i = 0 ; i < aConfigCategory.getChildren().size(); i++) { + GT_UO_Fluid fluid = new GT_UO_Fluid((ConfigCategory)aConfigCategory.getChildren().toArray()[i]); + fFluids.put(fluid.Registry, fluid); + maxChance += fluid.Chance; + } + } + + public GT_UO_Fluid getRandomFluid (Random aRandom) { + int random = aRandom.nextInt(3); + random = aRandom.nextInt(1000); + int step = 0; + for (BiMap.Entry<String, GT_UO_Fluid> fl : fFluids.entrySet()) { + int chance = fl.getValue().Chance*1000/maxChance; + if (random<=chance) return fl.getValue(); + //System.out.println("GT UO "+fl.getValue().Registry+" Chance:"+chance+" Random:"+random); + random-=chance; + } + + return null; + + } + +} diff --git a/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java b/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java new file mode 100644 index 0000000000..89340132be --- /dev/null +++ b/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java @@ -0,0 +1,83 @@ +package gregtech.api.objects; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.Configuration; + +public class GT_UO_DimensionList { + + private Configuration fConfig; + private String fCategory; + private BiMap<String, GT_UO_Dimension> fDimensionList; + + public int[] BlackList; + + public GT_UO_DimensionList() { + fDimensionList = HashBiMap.create(); + } + + public GT_UO_Dimension GetDimension(int aDimension) { + if (fDimensionList.containsKey(Integer.toString(aDimension))) + return fDimensionList.get(Integer.toString(aDimension)); + for (BiMap.Entry <String, GT_UO_Dimension> dl : fDimensionList.entrySet()) + if (DimensionManager.getProvider(aDimension).getClass().getName().contains(dl.getValue().Dimension)) + return dl.getValue(); + return fDimensionList.get("Default"); + } + + public boolean CheckBlackList(int aDimensionId){ + try { + if (java.util.Arrays.binarySearch(BlackList, aDimensionId) >= 0) return true; + else return false; + } catch (Exception e) { + return false; + } + } + + public void SetConfigValues(String aDimensionName, String aDimension, String aName, String aRegistry, int aMinAmount, int aMaxAmount, int aChance, int aDecreasePerOperationAmount) { + String Category = fCategory+"."+aDimensionName; + fConfig.get(Category, "Dimension", aDimension).getString(); + Category+="."+aName; + fConfig.get(Category, "Registry", aRegistry).getString(); + fConfig.get(Category, "MinAmount", aMinAmount).getInt(aMinAmount); + fConfig.get(Category, "MaxAmount", aMaxAmount).getInt(aMaxAmount); + fConfig.get(Category, "Chance", aChance).getInt(aChance); + fConfig.get(Category, "DecreasePerOperationAmount", aDecreasePerOperationAmount).getInt(aDecreasePerOperationAmount); + } + + public void SetDafultValues() { + SetConfigValues("Overworld", "0", "gas_natural_gas", "gas_natural_gas", 0, 625, 20, 5); + SetConfigValues("Overworld", "0", "liquid_light_oil", "liquid_light_oil", 0, 625, 20, 5); + SetConfigValues("Overworld", "0", "liquid_medium_oil", "liquid_medium_oil", 0, 625, 20, 5); + SetConfigValues("Overworld", "0", "liquid_heavy_oil", "liquid_heavy_oil", 0, 625, 20, 5); + SetConfigValues("Overworld", "0", "oil", "oil", 0, 625, 20, 5); + SetConfigValues("Moon", "Moon", "helium-3", "helium-3", 0, 375, 100, 5); + } + + public void getConfig(Configuration aConfig, String aCategory) { + fCategory=aCategory; + fConfig = aConfig; + if (!fConfig.hasCategory(fCategory)) + SetDafultValues(); + + fConfig.setCategoryComment(fCategory, "Config Undeground Fluids (Delete this Category for regenerate)"); + fConfig.setCategoryComment(fCategory+".Default", "Set Default Generating (Use this Category for Default settings)"); + fConfig.setCategoryComment(fCategory+".Overworld", "Set Overworld Generating"); + fConfig.setCategoryComment(fCategory+".Moon", "Set Moon Generating"); + + int[] BlackList = {-1,1}; + BlackList = aConfig.get(fCategory, "DimBlackList", BlackList, "Dimension IDs Black List").getIntList(); + java.util.Arrays.sort(BlackList); + + for (int i = 0 ; i < fConfig.getCategory(fCategory).getChildren().size(); i++) { + GT_UO_Dimension Dimension = new GT_UO_Dimension((ConfigCategory)fConfig.getCategory(fCategory).getChildren().toArray()[i]); + fDimensionList.put(Dimension.Dimension, Dimension); + } + } + +} diff --git a/src/main/java/gregtech/api/objects/GT_UO_Fluid.java b/src/main/java/gregtech/api/objects/GT_UO_Fluid.java new file mode 100644 index 0000000000..c2d9b70bd2 --- /dev/null +++ b/src/main/java/gregtech/api/objects/GT_UO_Fluid.java @@ -0,0 +1,63 @@ +package gregtech.api.objects; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Random; + +import gregtech.api.enums.GT_Values; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +public class GT_UO_Fluid { + public String Registry = "null"; + public int MaxAmount = 0; + public int MinAmount = 0; + public int Chance = 0; + public int DecreasePerOperationAmount = 5; + + public GT_UO_Fluid(ConfigCategory aConfigCategory) { + if (aConfigCategory.containsKey("Registry")) + { + aConfigCategory.get("Registry").comment = "Fluid registry"; + Registry = aConfigCategory.get("Registry").getString(); + } + if (aConfigCategory.containsKey("MaxAmount")) + { + aConfigCategory.get("MaxAmount").comment = "Max amount generation (per operation Amount)"; + MaxAmount = aConfigCategory.get("MaxAmount").getInt(0); + } + if (aConfigCategory.containsKey("MinAmount")) + { + aConfigCategory.get("MinAmount").comment = "Max amount generation (per operation Amount)"; + MinAmount = aConfigCategory.get("MinAmount").getInt(0); + } + if (aConfigCategory.containsKey("Chance")) + { + aConfigCategory.get("Chance").comment = "Chance generating"; + Chance = aConfigCategory.get("Chance").getInt(0); + } + if (aConfigCategory.containsKey("DecreasePerOperationAmount")) + { + aConfigCategory.get("DecreasePerOperationAmount").comment = "Decrease per operation Amount (X/5000L per operation)"; + DecreasePerOperationAmount = aConfigCategory.get("DecreasePerOperationAmount").getInt(5); + } + //System.out.println("GT UO "+aConfigCategory.getName()+" Fluid:"+Registry+" Max:"+MaxAmount+" Min:"+MinAmount+" Chance:"+Chance); + } + + public Fluid getFluid(){ + try { + return FluidRegistry.getFluid(this.Registry); + } catch (Exception e) { + return null; + } + } + + public int getRandomAmount(Random aRandom){ + int r1 = (int)Math.round(Math.pow((MaxAmount-MinAmount)*500000.d, 0.2)); + int r2 = (int)Math.floor(Math.pow(MinAmount*500000.d, 0.2)); + double amount = aRandom.nextInt(r1)+r2+aRandom.nextDouble(); + return (int) (Math.pow(amount, 5) / 100); + } + +}
\ No newline at end of file diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index b3fffa5b47..cf70f21069 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -2,6 +2,7 @@ package gregtech.api.util; import cofh.api.transport.IItemDuct; import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.damagesources.GT_DamageSources; import gregtech.api.enchants.Enchantment_Radioactivity; @@ -17,6 +18,7 @@ import gregtech.api.items.GT_EnergyArmor_Item; import gregtech.api.items.GT_Generic_Item; import gregtech.api.net.GT_Packet_Sound; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_UO_Fluid; import gregtech.api.objects.ItemData; import gregtech.api.threads.GT_Runnable_Sound; import gregtech.common.GT_Proxy; @@ -1518,52 +1520,68 @@ public class GT_Utility { return false; } + public static int getScaleСoordinates(double aValue, int aScale) { + return (int)Math.floor(aValue / aScale); + } + public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) { return getUndergroundOil(aWorld, aX, aZ, false); } public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ, boolean needConsumeOil) { - - Random tRandom = new Random((aWorld.getSeed() + (aX / 96) + (7 * (aZ / 96)))); - int oil = tRandom.nextInt(3); - double amount = tRandom.nextInt(50) + tRandom.nextDouble(); - oil = tRandom.nextInt(4); -// System.out.println("Oil: "+(aX/96)+" "+(aZ/96)+" "+oil+" "+amount); -// amount = 40; + if (GT_Mod.gregtechproxy.mUndergroundOil.CheckBlackList(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 tAmount = 0; + int tFluidId = 0; + int tDecreasePerOperationAmount = 5; Fluid tFluid = null; - switch (oil) { - case 0: - tFluid = Materials.NatruralGas.mGas; - break; - case 1: - tFluid = Materials.OilLight.mFluid; - break; - case 2: - tFluid = Materials.OilMedium.mFluid; - break; - case 3: - tFluid = Materials.OilHeavy.mFluid; - break; - default: - tFluid = Materials.Oil.mFluid; - } - int tAmount = (int) (Math.pow(amount, 5) / 100); - ChunkPosition tPos = new ChunkPosition(aX/16, 1, aZ/16); - int[] tInts = new int[2]; +// System.out.println("Dimension: "+GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).Dimension); + try { + GT_UO_Fluid uoFluid = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).getRandomFluid(tRandom); + if (uoFluid != null) + { + tFluid = uoFluid.getFluid(); + tAmount = uoFluid.getRandomAmount(tRandom); + tDecreasePerOperationAmount = uoFluid.DecreasePerOperationAmount; + if (tFluid != null) + tFluidId = tFluid.getID(); + //System.out.println("Fluid: ("+tFluidId+")"+tFluid.getName()+" Amount:"+tAmount); + } + + } catch (Exception e) { + tAmount = 0; + tFluidId = 0; + } + + ChunkPosition tPos = new ChunkPosition(getScaleСoordinates(aX,16), aWorld.provider.dimensionId, getScaleСoordinates(aZ,16)); + int[] tInts = new int[0]; if(GT_Proxy.chunkData.containsKey(tPos)){ tInts = GT_Proxy.chunkData.get(tPos); if(tInts.length>0){ if(tInts[0]>0){tAmount = tInts[0];} } + if(tInts.length>2){ + if(tInts[2]>0&&tInts[2]!=tFluidId) + { + tFluidId = tInts[2]; + tFluid = FluidRegistry.getFluid(tFluidId); + } + } GT_Proxy.chunkData.remove(tPos); } + if (needConsumeOil && tAmount >= 5000) - tAmount = tAmount - 5; + tAmount = tAmount - tDecreasePerOperationAmount; + tInts[0] = tAmount; + tInts[2] = tFluidId; GT_Proxy.chunkData.put(tPos, tInts); - - return new FluidStack(tFluid, tAmount); + if (tFluid!=null) + return new FluidStack(tFluid, tAmount); + return null; } public static int getCoordinateScan(ArrayList<String> aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) { @@ -1756,10 +1774,11 @@ public class GT_Utility { } if (aPlayer.capabilities.isCreativeMode&>_Values.D1) { FluidStack tFluid = getUndergroundOil(aWorld, aX, aZ); - tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName()); + if (tFluid!=null) + tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName()); } // if(aPlayer.capabilities.isCreativeMode){ - ChunkPosition tPos = new ChunkPosition(aX>>4, 1, aZ>>4); + ChunkPosition tPos = new ChunkPosition(getScaleСoordinates(aX,16), aWorld.provider.dimensionId, getScaleСoordinates(aZ,16)); if(GT_Proxy.chunkData.containsKey(tPos)){ int[] tPollution = GT_Proxy.chunkData.get(tPos); if(tPollution.length>1){ @@ -2003,7 +2022,9 @@ public class GT_Utility { public static void setProspectionData(ItemStack aStack, int aX, int aY, int aZ, int aDim, FluidStack aFluid, String[] aOres) { NBTTagCompound tNBT = getNBT(aStack); - String tData = aX + "," + aY + "," + aZ + "," + aDim + "," + (aFluid.amount / 5000) + "," + aFluid.getLocalizedName() + ","; + String tData = aX + "," + aY + "," + aZ + "," + aDim + ","; + if (aFluid!=null) + tData += (aFluid.amount / 5000) + "," + aFluid.getLocalizedName() + ","; for (String tString : aOres) { tData += tString + ","; } @@ -2024,7 +2045,7 @@ public class GT_Utility { setBookTitle(aStack, "Raw Prospection Data"); NBTTagCompound tNBT = GT_Utility.ItemNBT.getNBT(aStack); - + tNBT.setByte("prospection_tier", aTier); tNBT.setString("prospection_pos", "X: " + aX + " Y: " + aY + " Z: " + aZ + " Dim: " + aDim); diff --git a/src/main/java/gregtech/common/GT_Pollution.java b/src/main/java/gregtech/common/GT_Pollution.java index 25b7521721..e57c44040f 100644 --- a/src/main/java/gregtech/common/GT_Pollution.java +++ b/src/main/java/gregtech/common/GT_Pollution.java @@ -187,12 +187,13 @@ public class GT_Pollution { else if(tBlock == Blocks.gravel){world.setBlock(x, y, z, Blocks.sand); } } } - - public static void addPollution(ChunkPosition aPos, int aPollution){ + + //Add aWorld to Save Pollution + public static void addPollution(World aWorld, ChunkPosition aPos, int aPollution){ if(!GT_Mod.gregtechproxy.mPollution)return; try{ - ChunkPosition tPos = new ChunkPosition(aPos.chunkPosX>>4, 1, aPos.chunkPosZ>>4); -// System.out.println("add pollution x: "+ tPos.chunkPosX +" z: " + tPos.chunkPosZ +" poll: "+aPollution); + ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleСoordinates(aPos.chunkPosX,16), aWorld.provider.dimensionId, GT_Utility.getScaleСoordinates(aPos.chunkPosZ,16)); // OLD in coordinate -1 -1 chunk 0 0 +// System.out.println("add pollution dim: "+aWorld.provider.dimensionId+" x: "+ tPos.chunkPosX +" z: " + tPos.chunkPosZ +" poll: "+aPollution); int[] tData = new int[2]; if(GT_Proxy.chunkData.containsKey(tPos)){ tData = GT_Proxy.chunkData.get(tPos); diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 49917dd7f8..1639007c29 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -24,6 +24,7 @@ import gregtech.api.items.GT_MetaGenerated_Item; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.objects.GT_Fluid; import gregtech.api.objects.GT_FluidStack; +import gregtech.api.objects.GT_UO_DimensionList; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.util.*; @@ -179,6 +180,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public int mPollutionPoisonLimit = 750000; public int mPollutionVegetationLimit = 1000000; public int mPollutionSourRainLimit = 2000000; + public final GT_UO_DimensionList mUndergroundOil = new GT_UO_DimensionList(); public int mTicksUntilNextCraftSound = 0; public double mMagneticraftBonusOutputPercent = 100.0d; private World mUniverse = null; @@ -1698,52 +1700,44 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { @SubscribeEvent public void handleChunkSaveEvent(ChunkDataEvent.Save event) - { - ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,1,event.getChunk().zPosition); + { + ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,event.getChunk().worldObj.provider.dimensionId,event.getChunk().zPosition); if(chunkData.containsKey(tPos)){ int[] tInts = chunkData.get(tPos); if(tInts.length>0){event.getData().setInteger("GTOIL", tInts[0]);} - if(tInts.length>1){event.getData().setInteger("GTPOLLUTION", tInts[1]);}} + if(tInts.length>1){event.getData().setInteger("GTPOLLUTION", tInts[1]);} + if(tInts.length>2){event.getData().setInteger("GTOILFLUID", tInts[2]);} + } } @SubscribeEvent public void handleChunkLoadEvent(ChunkDataEvent.Load event) { int tOil = 0; + int tOilFluid = 0; int tPollution = 0; - ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,1,event.getChunk().zPosition); - int[] tData = new int[2]; + ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,event.getChunk().worldObj.provider.dimensionId,event.getChunk().zPosition); + int[] tData = new int[0]; if(chunkData.containsKey(tPos)){ tData = chunkData.get(tPos); chunkData.remove(tPos); - } - - if(event.getData().hasKey("GTOIL")){ - if(tData.length>2){ - tOil = tData[0]; - }else{ - tOil += event.getData().getInteger("GTOIL"); - } - }else{ - if(tData[0]!=0){ + if(tData.length>0) tOil = tData[0]; - } + if(tData.length>1) + tPollution = tData[1]; + if(tData.length>2) + tOilFluid = tData[2]; } - if(event.getData().hasKey("GTPOLLUTION")){ - if(tData.length>2){ - tPollution = tData[1]; - }else{ - tPollution += event.getData().getInteger("GTPOLLUTION"); - } - }else{ - if(tData[1]!=0){ - tPollution = tData[1]; - } - } + if(tOil==0&&event.getData().hasKey("GTOIL")) + tOil = event.getData().getInteger("GTOIL"); + if(tPollution==0&&event.getData().hasKey("GTPOLLUTION")) + tPollution = event.getData().getInteger("GTPOLLUTION"); + if(tOilFluid==0&&event.getData().hasKey("GTOILFLUID")) + tOilFluid = event.getData().getInteger("GTOILFLUID"); - chunkData.put(tPos, new int[]{ tOil,tPollution,-1}); + chunkData.put(tPos, new int[]{tOil,tPollution,tOilFluid}); } public static class OreDictEventContainer { diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java index 776f71761e..5c6fdeeb33 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java @@ -141,7 +141,7 @@ public class GT_MetaTileEntity_Boiler_Bronze this.mTemperature += 1; } if(this.mProcessingEnergy>0 && (aTick % 20L == 0L)){ - GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 20); + GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 20); } aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java index 8480b03733..2806cbc943 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java @@ -120,7 +120,7 @@ public class GT_MetaTileEntity_Boiler_Lava }
if(this.mProcessingEnergy>0 && (aTick % 20L == 0L)){
- GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 20);
+ GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 20);
}
aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
}
diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java index 4016e7be35..c5ad432ad7 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java @@ -146,7 +146,7 @@ public class GT_MetaTileEntity_Boiler_Steel this.mTemperature += 1;
}
if(this.mProcessingEnergy>0 && (aTick % 20L == 0L)){
- GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 20);
+ GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 20);
}
aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java index e459c69adb..de3dcbb432 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java @@ -31,6 +31,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.ChunkPosition; import net.minecraftforge.fluids.FluidStack; public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_BasicMachine { @@ -103,7 +104,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba prospectOres(tNearOres, tMiddleOres, tFarOres); // prospecting oils - HashMap<String, Integer> tOils = new HashMap<String, Integer>(9); + HashMap<String, Integer> tOils = new HashMap<String, Integer>(); prospectOils(tOils); GT_Utility.ItemNBT.setAdvancedProspectionData(mTier, @@ -125,31 +126,35 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba private void prospectOils(HashMap<String, Integer> aOils) { - int tLeftXBound = this.getBaseMetaTileEntity().getXCoord() - radius; - int tRightXBound = tLeftXBound + 2*radius; - - int tLeftZBound = this.getBaseMetaTileEntity().getZCoord() - radius; - int tRightZBound = tLeftZBound + 2*radius; - - ArrayList<String> filterList = new ArrayList<String>(9); - String filter; - - for (int x = tLeftXBound; x <= tRightXBound; ++x) - for (int z = tLeftZBound; z <= tRightZBound; ++z) { - filter = x/96 + "," + z/96; - - if (!filterList.contains(filter)) { - filterList.add(filter); - - putOil((x/96)*96, (z/96)*96, aOils); + int tLeftXBound = GT_Utility.getScaleСoordinates(this.getBaseMetaTileEntity().getXCoord() - radius, 16); + int tRightXBound = GT_Utility.getScaleСoordinates(this.getBaseMetaTileEntity().getXCoord() + radius, 16); + + int tLeftZBound = GT_Utility.getScaleСoordinates(this.getBaseMetaTileEntity().getZCoord() - radius, 16); + int tRightZBound = GT_Utility.getScaleСoordinates(this.getBaseMetaTileEntity().getZCoord() + radius, 16); + + HashMap<ChunkPosition, FluidStack> tFluids = new HashMap<ChunkPosition, FluidStack>(); + + try { + for (int x = tLeftXBound; x <= tRightXBound; ++x) + for (int z = tLeftZBound; z <= tRightZBound; ++z) + { + ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleСoordinates(x*16,96), 0, GT_Utility.getScaleСoordinates(z*16,96)); + FluidStack tFluid = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), x*16, z*16); + if (tFluid != null) + if (tFluids.containsKey(tPos)) + { + if (tFluids.get(tPos).amount<tFluid.amount) + tFluids.get(tPos).amount = tFluid.amount; + } else if (tFluid.amount / 5000 > 0) + tFluids.put(tPos, tFluid); } - } - } - - private void putOil(int x, int z, HashMap<String, Integer> aOils) { - FluidStack tFluid = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), x, z); - if (tFluid.amount / 5000 > 0) - aOils.put(x + "," + z + "," + (tFluid.amount / 5000) + "," + tFluid.getLocalizedName(), tFluid.amount / 5000); + + for (HashMap.Entry<ChunkPosition, FluidStack> fl : tFluids.entrySet()) { + aOils.put(fl.getKey().chunkPosX + "," + fl.getKey().chunkPosZ + "," + (fl.getValue().amount / 5000) + "," + fl.getValue().getLocalizedName(), fl.getValue().amount / 5000); + } + } catch (Exception e) { + // TODO: handle exception + } } private void prospectOres(Map<String, Integer> aNearOres, Map<String, Integer> aMiddleOres, Map<String, Integer> aFarOres) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java index 89b9adaa7e..7efc667ade 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java @@ -209,7 +209,7 @@ public class GT_MetaTileEntity_BronzeBlastFurnace }
}
if(this.mMaxProgresstime>0 && (aTimer % 20L == 0L)){
- GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 50);
+ GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 50);
}
aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine));
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java index 22d901f13a..9c4881d18c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java @@ -86,7 +86,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock this.mEfficiency = 10000; this.mEfficiencyIncrease = 10000; this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), mMaxProgresstime*5); + GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), mMaxProgresstime*5); return true; } else { this.mEfficiency = 0; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java index eef57f9059..60863e4c52 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java @@ -75,6 +75,7 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase } FluidStack tFluid = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord(), true); if (tFluid == null) { + stopMachine(); return false; } if (getYOfPumpHead() > 0 && getBaseMetaTileEntity().getBlockOffset(ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX, getYOfPumpHead() - 1 - getBaseMetaTileEntity().getYCoord(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ) != Blocks.bedrock) { |