From 7926877ed18689ebca2fc170627bcb61d5ac13c0 Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Tue, 25 Oct 2016 20:22:56 +0200 Subject: [PATCH] Pollution Update/Rebalance --- .../metatileentity/BaseMetaTileEntity.java | 3 + .../GT_MetaTileEntity_BasicGenerator.java | 2 +- .../GT_MetaTileEntity_Hatch_Muffler.java | 10 ++- .../java/gregtech/common/GT_Pollution.java | 70 +++++++++++++++---- .../GT_MetaTileEntity_Boiler_Bronze.java | 2 +- .../GT_MetaTileEntity_Boiler_Lava.java | 2 +- .../GT_MetaTileEntity_Boiler_Steel.java | 2 +- .../GT_MetaTileEntity_BronzeBlastFurnace.java | 2 +- .../multi/GT_MetaTileEntity_Charcoal_Pit.java | 2 + .../multi/GT_MetaTileEntity_DieselEngine.java | 2 +- ...T_MetaTileEntity_ElectricBlastFurnace.java | 2 +- ...GT_MetaTileEntity_ImplosionCompressor.java | 2 +- .../multi/GT_MetaTileEntity_LargeBoiler.java | 2 +- .../GT_MetaTileEntity_LargeTurbine_Gas.java | 2 +- .../multi/GT_MetaTileEntity_MultiFurnace.java | 2 +- 15 files changed, 78 insertions(+), 29 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 2d2f5155..c45dca4a 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -12,6 +12,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.*; +import gregtech.common.GT_Pollution; import ic2.api.Direction; import net.minecraft.block.Block; import net.minecraft.block.BlockFire; @@ -25,6 +26,7 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.ChunkPosition; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -1118,6 +1120,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } } } + GT_Pollution.addPollution(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 e9c69574..8acd6fd5 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()), - (int) ((tProducedEU * getPollution()/500)+1)); + (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 b092df1e..6d0fdc46 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 @@ -12,7 +12,7 @@ import net.minecraft.world.ChunkPosition; public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Muffler(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Outputs the Pollution (Pollution might come later)"); + super(aID, aName, aNameRegional, aTier, 0, "Outputs the Pollution (Might cause acidic rains and poisoning)"); } public GT_MetaTileEntity_Hatch_Muffler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -21,7 +21,7 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { @Override public String[] getDescription() { - return new String[]{mDescription, "DO NOT OBSTRUCT THE OUTPUT!"}; + return new String[]{mDescription, "DO NOT OBSTRUCT THE OUTPUT!","Reduces Pollution to "+calculatePollutionReduction(100)+"%"}; } @Override @@ -60,9 +60,13 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { } public boolean polluteEnvironment() { - GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 1000 - (95*mTier)); + GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), calculatePollutionReduction(1000)); return (mTier > 1 && getBaseMetaTileEntity().getRandomNumber(mTier) != 0) || getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing()); } + + public int calculatePollutionReduction(int aPollution){ + return (int) (aPollution *(Math.pow(0.7, mTier-1))); + } @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { diff --git a/src/main/java/gregtech/common/GT_Pollution.java b/src/main/java/gregtech/common/GT_Pollution.java index 43935eff..ae1d6368 100644 --- a/src/main/java/gregtech/common/GT_Pollution.java +++ b/src/main/java/gregtech/common/GT_Pollution.java @@ -1,11 +1,11 @@ - package gregtech.common; +package gregtech.common; import gregtech.GT_Mod; import gregtech.api.objects.XSTR; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -18,7 +18,37 @@ import java.util.ArrayList; import java.util.List; public class GT_Pollution { - + /** + * Pollution dispersion until effects start: + * Calculation: ((Limit * 0.01) + 2000) * (4 <- spreading rate) + * + * SMOG(500k) 466.7 pollution/sec + * Poison(750k) 633,3 pollution/sec + * Dying Plants(1mio) 800 pollution/sec + * Sour Rain(1.5mio) 1133.3 pollution/sec + * + * Pollution producers (pollution/sec) + * Bronze Boiler(20) + * Lava Boiler(20) + * High Pressure Boiler(20) + * Bronze Blast Furnace(50) + * Diesel Generator(14/28/75) + * Gas Turbine(7/14/37) + * Charcoal Pile(100) + * + * Large Diesel Generator(300) + * Electric Blast Furnace(100) + * Implosion Compressor(2000) + * Large Boiler(240) + * Large Gas Turbine(160) + * Multi Smelter(100) + * Pyrolyse Oven(400) + * + * Machine Explosion(100,000) + * + * Muffler Hatch Pollution reduction: + * LV (0%), MV (30%), HV (52%), EV (66%), IV (76%), LuV (84%), ZPM (89%), UV (92%), MAX (95%) + */ static List tList = null; static int loops = 1; @@ -54,7 +84,7 @@ public class GT_Pollution { for(ChunkPosition tNPos : tNeighbor){ if(GT_Proxy.chunkData.containsKey(tNPos)){ int tNPol = GT_Proxy.chunkData.get(tNPos)[1]; - if(tNPol GT_Mod.gregtechproxy.mPollutionSmogLimit){ - + AxisAlignedBB chunk = AxisAlignedBB.getBoundingBox(tPos.chunkPosX<<4, 0, tPos.chunkPosZ<<4, tPos.chunkPosX<<4+16, 256, tPos.chunkPosZ<<4+16); + List tEntitys = aWorld.getEntitiesWithinAABB(EntityLivingBase.class, chunk); + for(EntityLivingBase tEnt : tEntitys){ + if(!GT_Utility.isWearingFullGasHazmat(tEnt) && tRan.nextInt(tPollution/2000) > 40){ + int ran = tRan.nextInt(3); + if(ran==0)tEnt.addPotionEffect(new PotionEffect(Potion.weakness.id, Math.min(tPollution/2500,1000), tPollution/400000)); + if(ran==1)tEnt.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, Math.min(tPollution/2500,1000), tPollution/400000)); + if(ran==2)tEnt.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, Math.min(tPollution/2500,1000), tPollution/400000)); + } +} // Poison effects if(tPollution > GT_Mod.gregtechproxy.mPollutionPoisonLimit){ - AxisAlignedBB chunk = AxisAlignedBB.getBoundingBox(tPos.chunkPosX*16, 0, tPos.chunkPosZ*16, tPos.chunkPosX*16+16, 256, tPos.chunkPosZ*16+16); - List tEntitys = aWorld.getEntitiesWithinAABB(EntityLiving.class, chunk); - for(EntityLiving tEnt : tEntitys){ - if(tRan.nextInt(tPollution/25000) > 20){ - tEnt.addPotionEffect(new PotionEffect(Potion.poison.id, tPollution/25000, 1)); - } + for(EntityLivingBase tEnt : tEntitys){ + if(!GT_Utility.isWearingFullGasHazmat(tEnt) && tRan.nextInt(tPollution/2000) > 20){ + int ran = tRan.nextInt(3); + if(ran==0)tEnt.addPotionEffect(new PotionEffect(Potion.poison.id, Math.min(tPollution/2500,1000), tPollution/500000)); + if(ran==1)tEnt.addPotionEffect(new PotionEffect(Potion.confusion.id, Math.min(tPollution/2500,1000), 1)); + if(ran==2)tEnt.addPotionEffect(new PotionEffect(Potion.blindness.id, Math.min(tPollution/2500,1000), 1)); +} } // killing plants if(tPollution > GT_Mod.gregtechproxy.mPollutionVegetationLimit){ int f = 20; for(;f<(tPollution/25000);f++){ - int x =tPos.chunkPosX*16+(tRan.nextInt(16));; + int x =tPos.chunkPosX<<4+(tRan.nextInt(16));; int y =60 +(-f+tRan.nextInt(f*2+1)); - int z =tPos.chunkPosZ*16+(tRan.nextInt(16)); + int z =tPos.chunkPosZ<<4+(tRan.nextInt(16)); damageBlock(x, y, z, tPollution > GT_Mod.gregtechproxy.mPollutionSourRainLimit); }}}} } @@ -151,7 +191,7 @@ public class GT_Pollution { public static void addPollution(ChunkPosition aPos, int aPollution){ if(!GT_Mod.gregtechproxy.mPollution)return; try{ - ChunkPosition tPos = new ChunkPosition(aPos.chunkPosX/16, 1, aPos.chunkPosZ/16); + ChunkPosition tPos = new ChunkPosition(aPos.chunkPosX>>4, 1, aPos.chunkPosZ>>4); // System.out.println("add pollution x: "+ tPos.chunkPosX +" z: " + tPos.chunkPosZ +" poll: "+aPollution); int[] tData = new int[2]; if(GT_Proxy.chunkData.containsKey(tPos)){ 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 e82acfa5..776f7176 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()), 30); + GT_Pollution.addPollution(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 57ab2dd1..8480b037 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()), 30); + GT_Pollution.addPollution(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 abf9755c..4016e7be 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()), 30); + GT_Pollution.addPollution(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/multi/GT_MetaTileEntity_BronzeBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java index beb4be73..89b9adaa 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()), 200); + GT_Pollution.addPollution(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 c0ffd9aa..fbb1b986 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 @@ -9,6 +9,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; +import gregtech.common.GT_Pollution; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; @@ -85,6 +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); return true; } else { this.mEfficiency = 0; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index 5f221cf0..27687323 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -215,7 +215,7 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock @Override public int getPollutionPerTick(ItemStack aStack) { - return 0; + return 15; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 66f3c670..2f058e6e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -218,7 +218,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace } public int getPollutionPerTick(ItemStack aStack) { - return 10; + return 5; } public int getDamageToComponent(ItemStack aStack) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java index c5f6f111..37d93815 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java @@ -139,7 +139,7 @@ public class GT_MetaTileEntity_ImplosionCompressor } public int getPollutionPerTick(ItemStack aStack) { - return 1000; + return 100; } public int getDamageToComponent(ItemStack aStack) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java index b9411d38..bb7c6595 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java @@ -222,7 +222,7 @@ public abstract class GT_MetaTileEntity_LargeBoiler } public int getPollutionPerTick(ItemStack aStack) { - return 10; + return 12; } public int getDamageToComponent(ItemStack aStack) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index 501fac31..3e3b7acf 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -77,7 +77,7 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT @Override public int getPollutionPerTick(ItemStack aStack) { - return 10; + return 8; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index 8a608bf8..5677c3a7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -181,7 +181,7 @@ public class GT_MetaTileEntity_MultiFurnace } public int getPollutionPerTick(ItemStack aStack) { - return 20; + return 5; } public int getDamageToComponent(ItemStack aStack) {