From 3ce817dddb759a6aa3eb15bf35cd5b1fe988ab6e Mon Sep 17 00:00:00 2001 From: Dream-Master Date: Mon, 4 Jul 2016 18:41:53 +0200 Subject: [PATCH] More Pollution work --- .../java/gregtech/api/util/GT_Utility.java | 11 + src/main/java/gregtech/common/GT_Proxy.java | 44 ++- .../GT_MetaTileEntity_Boiler_Lava.java.orig | 275 ------------------ 3 files changed, 48 insertions(+), 282 deletions(-) delete mode 100644 src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java.orig diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8025d68f..e94e432e 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1758,6 +1758,17 @@ public class GT_Utility { FluidStack tFluid = getUndergroundOil(aWorld, aX, aZ); tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName()); } + if(aPlayer.capabilities.isCreativeMode){ + ChunkPosition tPos = new ChunkPosition(aX, aY, aZ); + if(GT_Proxy.chunkData.containsKey(tPos)){ + int[] tPollution = GT_Proxy.chunkData.get(tPos); + if(tPollution.length>1){ + tList.add("Pollution in Chunk: "+tPollution[1]); + }else{ + tList.add("No Pollution in Chunk"); + } + } + } try { if (tBlock instanceof IDebugableBlock) { diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 2335aa31..9ed45dd8 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1446,6 +1446,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { } } } + GT_Pollution.onWorldTick((int) (aEvent.world.getTotalWorldTime() % 1200)); } } @@ -1923,23 +1924,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_Lava.java.orig b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java.orig deleted file mode 100644 index 694b6cf3..00000000 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java.orig +++ /dev/null @@ -1,275 +0,0 @@ -<<<<<<< HEAD -package gregtech.common.tileentities.boilers; - -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -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.gui.GT_Container_Boiler; -import gregtech.common.gui.GT_GUIContainer_Boiler; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; - -public class GT_MetaTileEntity_Boiler_Lava - extends GT_MetaTileEntity_Boiler { - public GT_MetaTileEntity_Boiler_Lava(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional, "A Boiler running off Lava", new ITexture[0]); - } - - public GT_MetaTileEntity_Boiler_Lava(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[5][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; - rTextures[1][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_TOP, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE)}; - rTextures[2][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE)}; - rTextures[3][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT)}; - rTextures[4][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE)}; - } - return rTextures; - } - - public int maxProgresstime() { - return 1000; - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 32000); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_Lava(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { - if (this.mTemperature <= 20) { - this.mTemperature = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 20) { - this.mTemperature -= 1; - this.mLossTimer = 0; - } - for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte) (i + 1)) { - if (i != aBaseMetaTileEntity.getFrontFacing()) { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) { - FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) { - int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - } - if (aTick % 10L == 0L) { - if (this.mTemperature > 100) { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { - this.mHadNoWater = true; - } else { - if (this.mHadNoWater) { - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= 1; - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(300L); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += 300; - } else { - this.mSteam = GT_ModHandler.getSteam(300L); - } - } - } else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > 32000)) { - sendSound((byte) 1); - this.mSteam.amount = 24000; - } - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && - (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(Materials.Lava)))) { - this.mProcessingEnergy += 1000; - aBaseMetaTileEntity.decrStackSize(2, 1); - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); - } - if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 8L == 0L)) { - this.mProcessingEnergy -= 3; - this.mTemperature += 1; - } - aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); - } - } - - public final int fill(FluidStack aFluid, boolean doFill) { - if ((GT_ModHandler.isLava(aFluid)) && (this.mProcessingEnergy < 50)) { - int tFilledAmount = Math.min(50, aFluid.amount); - if (doFill) { - this.mProcessingEnergy += tFilledAmount; - } - return tFilledAmount; - } - return super.fill(aFluid, doFill); - } -} -======= -package gregtech.common.tileentities.boilers; - -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -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; - -public class GT_MetaTileEntity_Boiler_Lava - extends GT_MetaTileEntity_Boiler { - public GT_MetaTileEntity_Boiler_Lava(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional, "A Boiler running off Lava", new ITexture[0]); - } - - public GT_MetaTileEntity_Boiler_Lava(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[5][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; - rTextures[1][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_TOP, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE)}; - rTextures[2][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE)}; - rTextures[3][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT)}; - rTextures[4][(i + 1)] = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE)}; - } - return rTextures; - } - - public int maxProgresstime() { - return 1000; - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 32000); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_Lava(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { - if (this.mTemperature <= 20) { - this.mTemperature = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 20) { - this.mTemperature -= 1; - this.mLossTimer = 0; - } - for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte) (i + 1)) { - if (i != aBaseMetaTileEntity.getFrontFacing()) { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) { - FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) { - int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - } - if (aTick % 10L == 0L) { - if (this.mTemperature > 100) { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { - this.mHadNoWater = true; - } else { - if (this.mHadNoWater) { - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= 1; - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(300L); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += 300; - } else { - this.mSteam = GT_ModHandler.getSteam(300L); - } - } - } else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > 32000)) { - sendSound((byte) 1); - this.mSteam.amount = 24000; - } - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && - (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(Materials.Lava)))) { - this.mProcessingEnergy += 1000; - aBaseMetaTileEntity.decrStackSize(2, 1); - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); - } - if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 8L == 0L)) { - 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); - } - } - - public final int fill(FluidStack aFluid, boolean doFill) { - if ((GT_ModHandler.isLava(aFluid)) && (this.mProcessingEnergy < 50)) { - int tFilledAmount = Math.min(50, aFluid.amount); - if (doFill) { - this.mProcessingEnergy += tFilledAmount; - } - return tFilledAmount; - } - return super.fill(aFluid, doFill); - } -} ->>>>>>> 57deb3b... Pollution basework