diff options
author | Technus <daniel112092@gmail.com> | 2016-10-02 14:23:41 +0200 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2016-10-02 14:23:41 +0200 |
commit | 101e5170d7d305bbd88274998f8fcfceadfaf697 (patch) | |
tree | 0c9aa056d5616b8d662744139509872dd11d84d6 /src/main/java/gregtech | |
parent | eac8e5884ac15d9f4c3e78f033f2b302203b12fe (diff) | |
download | GT5-Unofficial-101e5170d7d305bbd88274998f8fcfceadfaf697.tar.gz GT5-Unofficial-101e5170d7d305bbd88274998f8fcfceadfaf697.tar.bz2 GT5-Unofficial-101e5170d7d305bbd88274998f8fcfceadfaf697.zip |
Readd pollution done
Diffstat (limited to 'src/main/java/gregtech')
16 files changed, 141 insertions, 7 deletions
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 bbb16a8adb..e8c8ce5d98 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 @@ -5,10 +5,12 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.common.GT_Pollution; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.world.ChunkPosition; import net.minecraftforge.fluids.FluidStack; import java.util.Collection; @@ -177,6 +179,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) { + long tProducedEU = 0; if (mFluid == null) { if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { mInventory[getStackDisplaySlot()] = null; @@ -190,6 +193,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) { long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) + tProducedEU = tFluidAmountToUse * tFuelValue; mFluid.amount -= tFluidAmountToUse * tConsumed; } } @@ -200,14 +204,21 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + tProducedEU = tFuelValue; } } } + if(tProducedEU>0&&getPollution()>0){ + GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), + (int) ((tProducedEU * getPollution()/500)+1)); + } } if (aBaseMetaTileEntity.isServerSide()) aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); } + + public abstract int getPollution(); public abstract GT_Recipe_Map getRecipes(); 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 8d6a3c0e81..b092df1e0c 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 @@ -5,8 +5,10 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.common.GT_Pollution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +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) { @@ -58,6 +60,7 @@ 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)); return (mTier > 1 && getBaseMetaTileEntity().getRandomNumber(mTier) != 0) || getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing()); } diff --git a/src/main/java/gregtech/common/GT_Pollution.java b/src/main/java/gregtech/common/GT_Pollution.java index e69de29bb2..feeeafe4b0 100644 --- a/src/main/java/gregtech/common/GT_Pollution.java +++ b/src/main/java/gregtech/common/GT_Pollution.java @@ -0,0 +1,28 @@ +package gregtech.common; + +import net.minecraft.world.ChunkPosition; + +public class GT_Pollution { + + +// List<ChunkPosition> list = new ArrayList<ChunkPosition>(chunkData.keySet()); + + public static void onWorldTick(int aTick){ + + } + + public static void addPollution(ChunkPosition aPos, int aPollution){ + int[] tData = new int[2]; + if(GT_Proxy.chunkData.containsKey(aPos)){ + tData = GT_Proxy.chunkData.get(aPos); + if(tData.length>1){ + tData[1] += aPollution; + } + GT_Proxy.chunkData.replace(aPos, tData); + }else{ + tData[1] += aPollution; + GT_Proxy.chunkData.put(aPos, tData); + } + + } +} diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 96817f9201..db337654dc 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1443,6 +1443,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { } } } + GT_Pollution.onWorldTick((int) (aEvent.world.getTotalWorldTime() % 1200)); } } @@ -1921,23 +1922,52 @@ 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); if(chunkData.containsKey(tPos)){ int[] tInts = chunkData.get(tPos); - if(tInts.length>0){event.getData().setInteger("GTOIL", tInts[0]);}} + if(tInts.length>0){event.getData().setInteger("GTOIL", tInts[0]);} + if(tInts.length>1){event.getData().setInteger("GTPOLLUTION", tInts[1]);}} } @SubscribeEvent public void handleChunkLoadEvent(ChunkDataEvent.Load event) { - int tOil = -1; - if(event.getData().hasKey("GTOIL")){ - tOil = event.getData().getInteger("GTOIL");} + int tOil = 0; + int tPollution = 0; + ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,1,event.getChunk().zPosition); + int[] tData = new int[2]; if(chunkData.containsKey(tPos)){ - chunkData.remove(tPos);} - chunkData.put(tPos, new int[]{ tOil}); + 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){ + tOil = tData[0]; + } + } + + 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]; + } + } + + chunkData.put(tPos, new int[]{ tOil,tPollution,-1}); } 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 dfe74e34fe..e82acfa561 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 @@ -10,9 +10,11 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.GT_Pollution; import gregtech.common.gui.GT_Container_Boiler; import gregtech.common.gui.GT_GUIContainer_Boiler; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.world.ChunkPosition; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; @@ -138,6 +140,9 @@ public class GT_MetaTileEntity_Boiler_Bronze this.mProcessingEnergy -= 1; 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); + } 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 a82f8e5e74..690def8414 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 @@ -10,9 +10,11 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.GT_Pollution; import gregtech.common.gui.GT_Container_Boiler; import gregtech.common.gui.GT_GUIContainer_Boiler; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.world.ChunkPosition; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; @@ -116,6 +118,10 @@ public class GT_MetaTileEntity_Boiler_Lava this.mProcessingEnergy -= 3; 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); + } 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 e9751a2d31..6a3fa610c9 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 @@ -10,9 +10,11 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.GT_Pollution; import gregtech.common.gui.GT_Container_Boiler; import gregtech.common.gui.GT_GUIContainer_Boiler; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.world.ChunkPosition; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; @@ -143,6 +145,9 @@ public class GT_MetaTileEntity_Boiler_Steel this.mProcessingEnergy -= 2; 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); + } aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); } } diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java index 14c4e58c76..2e383ded28 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java @@ -100,4 +100,9 @@ public class GT_MetaTileEntity_DieselGenerator public ITexture[] getSidesActive(byte aColor) { return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE)}; } + + @Override + public int getPollution() { + return 10; + } } diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_FluidNaquadahReactor.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_FluidNaquadahReactor.java index 101d38721c..34f714f282 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_FluidNaquadahReactor.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_FluidNaquadahReactor.java @@ -87,4 +87,9 @@ public class GT_MetaTileEntity_FluidNaquadahReactor public ITexture[] getSidesActive(byte aColor) { return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE)}; } + + @Override + public int getPollution() { + return 0; + } } diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java index 3c311e5e74..0e1509e0f4 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java @@ -89,4 +89,9 @@ public class GT_MetaTileEntity_GasTurbine public ITexture[] getSidesActive(byte aColor) { return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.GAS_TURBINE_SIDE_ACTIVE)}; } + + @Override + public int getPollution() { + return 5; + } } diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java index 5007c9a907..17e6412688 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java @@ -89,4 +89,9 @@ public class GT_MetaTileEntity_MagicEnergyConverter public ITexture[] getSidesActive(byte aColor) { return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; } + + @Override + public int getPollution() { + return 0; + } }
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java index 36d5f0b3b9..a2abde8815 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java @@ -283,4 +283,9 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B public ITexture[] getSidesActive(byte aColor) { return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; } + + @Override + public int getPollution() { + return 0; + } }
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java index 6f514dd3c3..555b44f020 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java @@ -89,4 +89,9 @@ public class GT_MetaTileEntity_PlasmaGenerator public ITexture[] getSidesActive(byte aColor) { return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW)}; } + + @Override + public int getPollution() { + return 0; + } }
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SolidNaquadahReactor.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SolidNaquadahReactor.java index a477e31851..8df1a1ad7a 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SolidNaquadahReactor.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SolidNaquadahReactor.java @@ -87,4 +87,9 @@ public class GT_MetaTileEntity_SolidNaquadahReactor public ITexture[] getSidesActive(byte aColor) { return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_SIDE_ACTIVE)}; } + + @Override + public int getPollution() { + return 0; + } } diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java index 870d61d5fa..90cd729da0 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java @@ -104,4 +104,9 @@ public class GT_MetaTileEntity_SteamTurbine extends GT_MetaTileEntity_BasicGener public ITexture[] getSidesActive(byte aColor) { return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE)}; } + + @Override + public int getPollution() { + return 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 1518915b39..94a9db6a08 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 @@ -13,6 +13,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.objects.XSTR; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Pollution; import gregtech.common.gui.GT_Container_BronzeBlastFurnace; import gregtech.common.gui.GT_GUIContainer_BronzeBlastFurnace; import net.minecraft.entity.player.EntityPlayer; @@ -21,6 +22,7 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.ChunkPosition; import net.minecraftforge.common.util.ForgeDirection; public class GT_MetaTileEntity_BronzeBlastFurnace @@ -209,6 +211,10 @@ public class GT_MetaTileEntity_BronzeBlastFurnace checkRecipe(); } } + if(this.mMaxProgresstime>0 && (aTimer % 20L == 0L)){ + GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 200); + } + aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); if (aBaseMetaTileEntity.isActive()) { if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { |