Fix generating Pollution in to other worlds

This commit is contained in:
Maxime Legkiy 2017-02-07 13:34:31 +03:00
parent d3a72491b4
commit 6567820a9b
10 changed files with 19 additions and 12 deletions

View file

@ -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);
}
}

View file

@ -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));
}
}

View file

@ -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;

View file

@ -1781,7 +1781,7 @@ public class GT_Utility {
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+1, getScaleСoordinates(aZ,16));
if(GT_Proxy.chunkData.containsKey(tPos)){
int[] tPollution = GT_Proxy.chunkData.get(tPos);
if(tPollution.length>1){

View file

@ -9,6 +9,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
@ -187,12 +188,18 @@ public class GT_Pollution {
else if(tBlock == Blocks.gravel){world.setBlock(x, y, z, Blocks.sand); }
}
}
//Backward compatibility (NOT USE)
public static void addPollution(ChunkPosition aPos, int aPollution){
addPollution(MinecraftServer.getServer().worldServerForDimension(0), aPos, 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 + 1, 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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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));

View file

@ -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;