From 704d534b4330beb674f25f961ae5056f65f68399 Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Sun, 3 Jul 2016 18:35:51 +0200 Subject: [PATCH] More Pollution work --- .../java/gregtech/api/util/GT_Utility.java | 11 +++++ src/main/java/gregtech/common/GT_Proxy.java | 44 ++++++++++++++++--- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 6a91675c..29c5ab2c 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1738,6 +1738,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 cd803aa1..c6090fe8 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1445,6 +1445,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { } } } + GT_Pollution.onWorldTick((int) (aEvent.world.getTotalWorldTime() % 1200)); } } @@ -1917,23 +1918,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 {