parent
7a08da6a06
commit
82458fed2e
20 changed files with 538 additions and 248 deletions
|
@ -1,8 +1,10 @@
|
||||||
package gregtech.api.interfaces.tileentity;
|
package gregtech.api.interfaces.tileentity;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
|
import gregtech.GT_Mod;
|
||||||
import gregtech.api.GregTech_API;
|
import gregtech.api.GregTech_API;
|
||||||
import gregtech.api.util.GT_Utility;
|
import gregtech.api.util.GT_Utility;
|
||||||
|
import gregtech.common.GT_Pollution;
|
||||||
import ic2.api.energy.tile.IEnergySink;
|
import ic2.api.energy.tile.IEnergySink;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -85,6 +87,8 @@ public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAnd
|
||||||
GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ);
|
GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ);
|
||||||
tWorld.setBlock(tX, tY, tZ, Blocks.air);
|
tWorld.setBlock(tX, tY, tZ, Blocks.air);
|
||||||
if (GregTech_API.sMachineExplosions)
|
if (GregTech_API.sMachineExplosions)
|
||||||
|
if(GT_Mod.gregtechproxy.mPollution)
|
||||||
|
GT_Pollution.addPollution(tWorld.getChunkFromBlockCoords(tX,tZ), 100000);
|
||||||
tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
|
tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1146,7 +1146,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GT_Pollution.addPollution(getWorld(), new ChunkPosition(getXCoord(), getYCoord(), getZCoord()), 100000);
|
|
||||||
|
GT_Pollution.addPollution(this, 100000);
|
||||||
mMetaTileEntity.doExplosion(aAmount);
|
mMetaTileEntity.doExplosion(aAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package gregtech.api.metatileentity;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import gregtech.GT_Mod;
|
||||||
import gregtech.api.GregTech_API;
|
import gregtech.api.GregTech_API;
|
||||||
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
|
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
|
||||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||||
|
@ -9,6 +10,7 @@ import gregtech.api.objects.GT_ItemStack;
|
||||||
import gregtech.api.util.GT_Config;
|
import gregtech.api.util.GT_Config;
|
||||||
import gregtech.api.util.GT_LanguageManager;
|
import gregtech.api.util.GT_LanguageManager;
|
||||||
import gregtech.api.util.GT_Utility;
|
import gregtech.api.util.GT_Utility;
|
||||||
|
import gregtech.common.GT_Pollution;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
@ -645,6 +647,8 @@ public abstract class MetaPipeEntity implements IMetaTileEntity {
|
||||||
World tWorld = getBaseMetaTileEntity().getWorld();
|
World tWorld = getBaseMetaTileEntity().getWorld();
|
||||||
tWorld.setBlock(tX, tY, tZ, Blocks.air);
|
tWorld.setBlock(tX, tY, tZ, Blocks.air);
|
||||||
if (GregTech_API.sMachineExplosions)
|
if (GregTech_API.sMachineExplosions)
|
||||||
|
if(GT_Mod.gregtechproxy.mPollution)
|
||||||
|
GT_Pollution.addPollution(getBaseMetaTileEntity(), 100000);
|
||||||
tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
|
tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,8 +203,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
|
||||||
if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) {
|
if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) {
|
||||||
long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);
|
long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);
|
||||||
if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) {
|
if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) {
|
||||||
GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()),
|
GT_Pollution.addPollution(getBaseMetaTileEntity(),10 * getPollution());
|
||||||
10 * getPollution());
|
|
||||||
mFluid.amount -= tFluidAmountToUse * tConsumed;
|
mFluid.amount -= tFluidAmountToUse * tConsumed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,8 +215,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
|
||||||
if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) {
|
if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) {
|
||||||
aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true);
|
aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true);
|
||||||
aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
|
aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
|
||||||
GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()),
|
GT_Pollution.addPollution(getBaseMetaTileEntity(),10 * getPollution());
|
||||||
10 * getPollution());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
package gregtech.api.metatileentity.implementations;
|
package gregtech.api.metatileentity.implementations;
|
||||||
|
|
||||||
|
import gregtech.GT_Mod;
|
||||||
import gregtech.api.enums.Textures;
|
import gregtech.api.enums.Textures;
|
||||||
import gregtech.api.interfaces.ITexture;
|
import gregtech.api.interfaces.ITexture;
|
||||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||||
import gregtech.api.metatileentity.MetaTileEntity;
|
import gregtech.api.metatileentity.MetaTileEntity;
|
||||||
import gregtech.api.objects.GT_RenderedTexture;
|
import gregtech.api.objects.GT_RenderedTexture;
|
||||||
|
import gregtech.api.objects.XSTR;
|
||||||
import gregtech.common.GT_Pollution;
|
import gregtech.common.GT_Pollution;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
|
public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
|
||||||
public GT_MetaTileEntity_Hatch_Muffler(int aID, String aName, String aNameRegional, int aTier) {
|
public GT_MetaTileEntity_Hatch_Muffler(int aID, String aName, String aNameRegional, int aTier) {
|
||||||
|
@ -69,7 +73,7 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
|
||||||
|
|
||||||
public boolean polluteEnvironment() {
|
public boolean polluteEnvironment() {
|
||||||
if (getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing())) {
|
if (getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing())) {
|
||||||
GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), calculatePollutionReduction(10000));
|
GT_Pollution.addPollution(getBaseMetaTileEntity(), calculatePollutionReduction(10000));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -88,4 +92,57 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
|
||||||
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
|
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
|
||||||
|
super.onPostTick(aBaseMetaTileEntity, aTick);
|
||||||
|
if(aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive())
|
||||||
|
pollutionParticles(this.getBaseMetaTileEntity().getWorld(),"largesmoke");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static XSTR floatGen=new XSTR();
|
||||||
|
|
||||||
|
public void pollutionParticles(World aWorld,String name){
|
||||||
|
boolean chk1,chk2,chk3;
|
||||||
|
float ran1=floatGen.nextFloat(),ran2=0,ran3=0;
|
||||||
|
chk1=ran1*100<calculatePollutionReduction(100);
|
||||||
|
if(GT_Pollution.getPollution(getBaseMetaTileEntity())>= GT_Mod.gregtechproxy.mPollutionSmogLimit){
|
||||||
|
ran2=floatGen.nextFloat();
|
||||||
|
ran3=floatGen.nextFloat();
|
||||||
|
chk2=ran2*100<calculatePollutionReduction(100);
|
||||||
|
chk3=ran3*100<calculatePollutionReduction(100);
|
||||||
|
if(!(chk1||chk2||chk3))return;
|
||||||
|
}else{
|
||||||
|
if(!chk1)return;
|
||||||
|
chk2=chk3=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IGregTechTileEntity aMuffler=this.getBaseMetaTileEntity();
|
||||||
|
ForgeDirection aDir=ForgeDirection.getOrientation(aMuffler.getFrontFacing());
|
||||||
|
float xPos=aDir.offsetX*0.76F+aMuffler.getXCoord()+0.25F;
|
||||||
|
float yPos=aDir.offsetY*0.76F+aMuffler.getYCoord()+0.25F;
|
||||||
|
float zPos=aDir.offsetZ*0.76F+aMuffler.getZCoord()+0.25F;
|
||||||
|
|
||||||
|
float ySpd=aDir.offsetY*0.1F+0.2F+0.1F*floatGen.nextFloat();
|
||||||
|
float xSpd;
|
||||||
|
float zSpd;
|
||||||
|
|
||||||
|
if(aDir.offsetY==-1){
|
||||||
|
float temp=floatGen.nextFloat()*2*(float)Math.PI;
|
||||||
|
xSpd=(float)Math.sin(temp)*0.1F;
|
||||||
|
zSpd=(float)Math.cos(temp)*0.1F;
|
||||||
|
}else{
|
||||||
|
xSpd=aDir.offsetX*(0.1F+0.2F*floatGen.nextFloat());
|
||||||
|
zSpd=aDir.offsetZ*(0.1F+0.2F*floatGen.nextFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(chk1)
|
||||||
|
aWorld.spawnParticle(name, xPos + ran1*0.5F, yPos + floatGen.nextFloat()*0.5F, zPos + floatGen.nextFloat()*0.5F, xSpd, ySpd, zSpd);
|
||||||
|
|
||||||
|
if(chk2)
|
||||||
|
aWorld.spawnParticle(name, xPos + ran2*0.5F, yPos + floatGen.nextFloat()*0.5F, zPos + floatGen.nextFloat()*0.5F, xSpd, ySpd, zSpd);
|
||||||
|
|
||||||
|
if(chk3)
|
||||||
|
aWorld.spawnParticle(name, xPos + ran3*0.5F, yPos + floatGen.nextFloat()*0.5F, zPos + floatGen.nextFloat()*0.5F, xSpd, ySpd, zSpd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import gregtech.api.util.GT_ModHandler;
|
||||||
import gregtech.api.util.GT_OreDictUnificator;
|
import gregtech.api.util.GT_OreDictUnificator;
|
||||||
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
|
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
|
||||||
import gregtech.api.util.GT_Utility;
|
import gregtech.api.util.GT_Utility;
|
||||||
|
import gregtech.common.GT_Pollution;
|
||||||
import gregtech.common.items.GT_MetaGenerated_Tool_01;
|
import gregtech.common.items.GT_MetaGenerated_Tool_01;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
@ -490,6 +491,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void explodeMultiblock() {
|
public void explodeMultiblock() {
|
||||||
|
GT_Pollution.addPollution(getBaseMetaTileEntity(), 300000);
|
||||||
mInventory[1] = null;
|
mInventory[1] = null;
|
||||||
for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
|
for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
|
||||||
for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
|
for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class GT_UO_Dimension {
|
||||||
private int maxChance;
|
private int maxChance;
|
||||||
public String Dimension = "null";
|
public String Dimension = "null";
|
||||||
|
|
||||||
public GT_UO_Dimension(ConfigCategory aConfigCategory) {
|
public GT_UO_Dimension(ConfigCategory aConfigCategory) {//TODO CONFIGURE
|
||||||
fFluids = HashBiMap.create();
|
fFluids = HashBiMap.create();
|
||||||
if (aConfigCategory.containsKey("Dimension"))
|
if (aConfigCategory.containsKey("Dimension"))
|
||||||
{
|
{
|
||||||
|
@ -35,18 +35,14 @@ public class GT_UO_Dimension {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GT_UO_Fluid getRandomFluid (Random aRandom) {
|
public GT_UO_Fluid getRandomFluid (Random aRandom) {
|
||||||
int random = aRandom.nextInt(3);
|
int random = aRandom.nextInt(1000);
|
||||||
random = aRandom.nextInt(1000);
|
|
||||||
int step = 0;
|
|
||||||
for (BiMap.Entry<String, GT_UO_Fluid> fl : fFluids.entrySet()) {
|
for (BiMap.Entry<String, GT_UO_Fluid> fl : fFluids.entrySet()) {
|
||||||
int chance = fl.getValue().Chance*1000/maxChance;
|
int chance = fl.getValue().Chance*1000/maxChance;
|
||||||
if (random<=chance) return fl.getValue();
|
if (random<=chance) return fl.getValue();
|
||||||
//System.out.println("GT UO "+fl.getValue().Registry+" Chance:"+chance+" Random:"+random);
|
//System.out.println("GT UO "+fl.getValue().Registry+" Chance:"+chance+" Random:"+random);
|
||||||
random-=chance;
|
random-=chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,15 +48,16 @@ public class GT_UO_DimensionList {
|
||||||
fConfig.get(Category, "MaxAmount", aMaxAmount).getInt(aMaxAmount);
|
fConfig.get(Category, "MaxAmount", aMaxAmount).getInt(aMaxAmount);
|
||||||
fConfig.get(Category, "Chance", aChance).getInt(aChance);
|
fConfig.get(Category, "Chance", aChance).getInt(aChance);
|
||||||
fConfig.get(Category, "DecreasePerOperationAmount", aDecreasePerOperationAmount).getInt(aDecreasePerOperationAmount);
|
fConfig.get(Category, "DecreasePerOperationAmount", aDecreasePerOperationAmount).getInt(aDecreasePerOperationAmount);
|
||||||
|
//IT IS IN BUCKETS!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDafultValues() {
|
public void SetDafultValues() {
|
||||||
SetConfigValues("Overworld", "0", "gas_natural_gas", "gas_natural_gas", 0, 625, 20, 5);
|
SetConfigValues("Overworld", "0", "gas_natural_gas", "gas_natural_gas", 0, 625, 20, 7);
|
||||||
SetConfigValues("Overworld", "0", "liquid_light_oil", "liquid_light_oil", 0, 625, 20, 5);
|
SetConfigValues("Overworld", "0", "liquid_light_oil", "liquid_light_oil", 0, 625, 20, 5);
|
||||||
SetConfigValues("Overworld", "0", "liquid_medium_oil", "liquid_medium_oil", 0, 625, 20, 5);
|
SetConfigValues("Overworld", "0", "liquid_medium_oil", "liquid_medium_oil", 0, 625, 20, 3);
|
||||||
SetConfigValues("Overworld", "0", "liquid_heavy_oil", "liquid_heavy_oil", 0, 625, 20, 5);
|
SetConfigValues("Overworld", "0", "liquid_heavy_oil", "liquid_heavy_oil", 0, 625, 20, 1);
|
||||||
SetConfigValues("Overworld", "0", "oil", "oil", 0, 625, 20, 5);
|
SetConfigValues("Overworld", "0", "oil", "oil", 0, 625, 20, 3);
|
||||||
SetConfigValues("Moon", "Moon", "helium-3", "helium-3", 0, 375, 100, 5);
|
SetConfigValues("Moon", "Moon", "helium-3", "helium-3", 1, 375, 100, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getConfig(Configuration aConfig, String aCategory) {
|
public void getConfig(Configuration aConfig, String aCategory) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class GT_UO_Fluid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRandomAmount(Random aRandom){
|
public int getRandomAmount(Random aRandom){//generates milliBuckets
|
||||||
int r1 = (int)Math.round(Math.pow((MaxAmount-MinAmount)*500000.d, 0.2));
|
int r1 = (int)Math.round(Math.pow((MaxAmount-MinAmount)*500000.d, 0.2));
|
||||||
int r2 = (int)Math.floor(Math.pow(MinAmount*500000.d, 0.2));
|
int r2 = (int)Math.floor(Math.pow(MinAmount*500000.d, 0.2));
|
||||||
double amount = aRandom.nextInt(r1)+r2+aRandom.nextDouble();
|
double amount = aRandom.nextInt(r1)+r2+aRandom.nextDouble();
|
||||||
|
|
|
@ -53,10 +53,13 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityChest;
|
import net.minecraft.tileentity.TileEntityChest;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.ChunkCoordIntPair;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
@ -73,6 +76,9 @@ import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import static gregtech.api.enums.GT_Values.*;
|
import static gregtech.api.enums.GT_Values.*;
|
||||||
|
import static gregtech.common.GT_Proxy.GTPOLLUTION;
|
||||||
|
import static gregtech.common.GT_Proxy.dimensionWiseChunkData;
|
||||||
|
import static gregtech.common.GT_UndergroundOil.undergroundOil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
|
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
|
||||||
|
@ -95,6 +101,14 @@ public class GT_Utility {
|
||||||
GregTech_API.sItemStackMappings.add(sFilledContainerToData);
|
GregTech_API.sItemStackMappings.add(sFilledContainerToData);
|
||||||
GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData);
|
GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int safeInt(long number, int margin){
|
||||||
|
return number>Integer.MAX_VALUE-margin ? Integer.MAX_VALUE-margin :(int)number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int safeInt(long number){
|
||||||
|
return number>GT_Values.V[GT_Values.V.length-1] ? safeInt(GT_Values.V[GT_Values.V.length-1],1) : number<Integer.MIN_VALUE ? Integer.MIN_VALUE : (int)number;
|
||||||
|
}
|
||||||
|
|
||||||
public static Field getPublicField(Object aObject, String aField) {
|
public static Field getPublicField(Object aObject, String aField) {
|
||||||
Field rField = null;
|
Field rField = null;
|
||||||
|
@ -1527,70 +1541,70 @@ public class GT_Utility {
|
||||||
return (int)Math.floor(aValue / aScale);
|
return (int)Math.floor(aValue / aScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) {
|
// public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) {
|
||||||
return getUndergroundOil(aWorld, aX, aZ, false);
|
// return getUndergroundOil(aWorld, aX, aZ, false);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ, boolean needConsumeOil) {
|
// public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ, boolean needConsumeOil) {
|
||||||
|
//
|
||||||
if (GT_Mod.gregtechproxy.mUndergroundOil.CheckBlackList(aWorld.provider.dimensionId))
|
// if (GT_Mod.gregtechproxy.mUndergroundOil.CheckBlackList(aWorld.provider.dimensionId))
|
||||||
return null;
|
// return null;
|
||||||
|
//
|
||||||
Random tRandom = new Random((aWorld.getSeed() + aWorld.provider.dimensionId * 2 + (getScaleCoordinates(aX,96)) + (7 * (getScaleCoordinates(aZ,96)))));
|
// Random tRandom = new Random((aWorld.getSeed() + aWorld.provider.dimensionId * 2 + (getScaleCoordinates(aX,96)) + (7 * (getScaleCoordinates(aZ,96)))));
|
||||||
int tAmount = 0;
|
// int tAmount = 0;
|
||||||
int tFluidId = 0;
|
// int tFluidId = 0;
|
||||||
int tDecreasePerOperationAmount = 5;
|
// int tDecreasePerOperationAmount = 5;
|
||||||
Fluid tFluid = null;
|
// Fluid tFluid = null;
|
||||||
// System.out.println("Dimension: "+GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).Dimension);
|
//// System.out.println("Dimension: "+GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).Dimension);
|
||||||
try {
|
// try {
|
||||||
GT_UO_Fluid uoFluid = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).getRandomFluid(tRandom);
|
// GT_UO_Fluid uoFluid = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).getRandomFluid(tRandom);
|
||||||
if (uoFluid != null)
|
// if (uoFluid != null)
|
||||||
{
|
// {
|
||||||
tFluid = uoFluid.getFluid();
|
// tFluid = uoFluid.getFluid();
|
||||||
tAmount = uoFluid.getRandomAmount(tRandom);
|
// tAmount = uoFluid.getRandomAmount(tRandom);
|
||||||
tDecreasePerOperationAmount = uoFluid.DecreasePerOperationAmount;
|
// tDecreasePerOperationAmount = uoFluid.DecreasePerOperationAmount;
|
||||||
if (tFluid != null)
|
// if (tFluid != null)
|
||||||
tFluidId = tFluid.getID();
|
// tFluidId = tFluid.getID();
|
||||||
//System.out.println("Fluid: ("+tFluidId+")"+tFluid.getName()+" Amount:"+tAmount);
|
// //System.out.println("Fluid: ("+tFluidId+")"+tFluid.getName()+" Amount:"+tAmount);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
tAmount = 0;
|
// tAmount = 0;
|
||||||
tFluidId = 0;
|
// tFluidId = 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
ChunkPosition tPos = new ChunkPosition(getScaleCoordinates(aX,16), aWorld.provider.dimensionId, getScaleCoordinates(aZ,16));
|
// ChunkPosition tPos = new ChunkPosition(getScaleCoordinates(aX,16), aWorld.provider.dimensionId, getScaleCoordinates(aZ,16));
|
||||||
int[] tInts = new int[3];
|
// int[] tInts = new int[3];
|
||||||
if(GT_Proxy.chunkData.containsKey(tPos)){
|
// if(GT_Proxy.chunkData.containsKey(tPos)){
|
||||||
tInts = GT_Proxy.chunkData.get(tPos);
|
// tInts = GT_Proxy.chunkData.get(tPos);
|
||||||
if(tInts.length>0){
|
// if(tInts.length>0){
|
||||||
if(tInts[0]>0){tAmount = tInts[0];}
|
// if(tInts[0]>0){tAmount = tInts[0];}
|
||||||
}
|
// }
|
||||||
if(tInts.length>2){
|
// if(tInts.length>2){
|
||||||
if(tInts[2]>0&&tInts[2]!=tFluidId)
|
// if(tInts[2]>0&&tInts[2]!=tFluidId)
|
||||||
{
|
// {
|
||||||
tFluidId = tInts[2];
|
// tFluidId = tInts[2];
|
||||||
tFluid = FluidRegistry.getFluid(tFluidId);
|
// tFluid = FluidRegistry.getFluid(tFluidId);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
GT_Proxy.chunkData.remove(tPos);
|
// GT_Proxy.chunkData.remove(tPos);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (needConsumeOil && tAmount >= 5000)
|
// if (needConsumeOil && tAmount >= 5000)
|
||||||
tAmount = tAmount - tDecreasePerOperationAmount;
|
// tAmount = tAmount - tDecreasePerOperationAmount;
|
||||||
|
//
|
||||||
tInts[0] = tAmount;
|
// tInts[0] = tAmount;
|
||||||
tInts[2] = tFluidId;
|
// tInts[2] = tFluidId;
|
||||||
GT_Proxy.chunkData.put(tPos, tInts);
|
// GT_Proxy.chunkData.put(tPos, tInts);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
System.out.println("getUndergroundOil() - Error put data");
|
// System.out.println("getUndergroundOil() - Error put data");
|
||||||
}
|
// }
|
||||||
if (tFluid!=null)
|
// if (tFluid!=null)
|
||||||
return new FluidStack(tFluid, tAmount);
|
// return new FluidStack(tFluid, tAmount);
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static int getCoordinateScan(ArrayList<String> aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) {
|
public static int getCoordinateScan(ArrayList<String> aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) {
|
||||||
if (aList == null) return 0;
|
if (aList == null) return 0;
|
||||||
|
|
||||||
|
@ -1779,22 +1793,25 @@ public class GT_Utility {
|
||||||
if (D1) e.printStackTrace(GT_Log.err);
|
if (D1) e.printStackTrace(GT_Log.err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aPlayer.capabilities.isCreativeMode&>_Values.D1) {
|
|
||||||
FluidStack tFluid = getUndergroundOil(aWorld, aX, aZ);
|
if (aPlayer.capabilities.isCreativeMode && GT_Values.D1) {
|
||||||
|
FluidStack tFluid = undergroundOil(aWorld.getChunkFromBlockCoords(aX,aZ),-1);//-# to only read
|
||||||
if (tFluid!=null)
|
if (tFluid!=null)
|
||||||
tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName());
|
tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+" L");
|
||||||
|
else
|
||||||
|
tList.add(EnumChatFormatting.GOLD+"Nothing"+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ '0' +EnumChatFormatting.RESET+" L");
|
||||||
}
|
}
|
||||||
// if(aPlayer.capabilities.isCreativeMode){
|
// if(aPlayer.capabilities.isCreativeMode){
|
||||||
ChunkPosition tPos = new ChunkPosition(getScaleCoordinates(aX,16), aWorld.provider.dimensionId, getScaleCoordinates(aZ,16));
|
int[] chunkData = GT_Proxy.dimensionWiseChunkData.get(aWorld.provider.dimensionId).get(aWorld.getChunkFromBlockCoords(aX,aZ).getChunkCoordIntPair());
|
||||||
if(GT_Proxy.chunkData.containsKey(tPos)){
|
if(chunkData !=null){
|
||||||
int[] tPollution = GT_Proxy.chunkData.get(tPos);
|
if(chunkData[GTPOLLUTION]>0){
|
||||||
if(tPollution.length>1){
|
tList.add("Pollution in Chunk: "+EnumChatFormatting.RED+chunkData[GTPOLLUTION]+EnumChatFormatting.RESET+" gibbl");
|
||||||
tList.add("Pollution in Chunk: "+tPollution[1]);
|
}else{
|
||||||
}else{
|
tList.add(EnumChatFormatting.GREEN+"No Pollution in Chunk! HAYO!"+EnumChatFormatting.RESET);
|
||||||
tList.add("No Pollution in Chunk");
|
}
|
||||||
}
|
}else{
|
||||||
}
|
tList.add(EnumChatFormatting.GREEN+"No Pollution in Chunk! HAYO!"+EnumChatFormatting.RESET);
|
||||||
// }
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (tBlock instanceof IDebugableBlock) {
|
if (tBlock instanceof IDebugableBlock) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package gregtech.common;
|
package gregtech.common;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import gregtech.GT_Mod;
|
import gregtech.GT_Mod;
|
||||||
|
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||||
import gregtech.api.objects.XSTR;
|
import gregtech.api.objects.XSTR;
|
||||||
import gregtech.api.util.GT_Utility;
|
import gregtech.api.util.GT_Utility;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -10,12 +12,17 @@ import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.potion.PotionEffect;
|
import net.minecraft.potion.PotionEffect;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.world.ChunkCoordIntPair;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
import static gregtech.common.GT_Proxy.*;
|
||||||
|
|
||||||
|
//import net.minecraft.entity.EntityLiving;
|
||||||
|
|
||||||
public class GT_Pollution {
|
public class GT_Pollution {
|
||||||
/**
|
/**
|
||||||
|
@ -49,95 +56,131 @@ public class GT_Pollution {
|
||||||
* Muffler Hatch Pollution reduction:
|
* Muffler Hatch Pollution reduction:
|
||||||
* LV (0%), MV (30%), HV (52%), EV (66%), IV (76%), LuV (84%), ZPM (89%), UV (92%), MAX (95%)
|
* LV (0%), MV (30%), HV (52%), EV (66%), IV (76%), LuV (84%), ZPM (89%), UV (92%), MAX (95%)
|
||||||
*/
|
*/
|
||||||
|
private static XSTR tRan = new XSTR();
|
||||||
|
private List<ChunkCoordIntPair> pollutionList = new ArrayList<>();//chunks left to process
|
||||||
|
private HashMap<ChunkCoordIntPair,int[]> chunkData;//link to chunk data that is saved/loaded
|
||||||
|
private int operationsPerTick=0;//how much chunks should be processed in each cycle
|
||||||
|
private static final short cycleLen=1200;
|
||||||
|
private final World aWorld;
|
||||||
|
|
||||||
static List<ChunkPosition> tList = null;
|
public GT_Pollution(World world){
|
||||||
static int loops = 1;
|
aWorld=world;
|
||||||
static XSTR tRan = new XSTR();
|
chunkData=dimensionWiseChunkData.get(aWorld.provider.dimensionId);
|
||||||
|
if(chunkData==null){
|
||||||
public static void onWorldTick(World aWorld, int aTick){
|
chunkData=new HashMap<>(1024);
|
||||||
if(!GT_Mod.gregtechproxy.mPollution)return;
|
dimensionWiseChunkData.put(world.provider.dimensionId,chunkData);
|
||||||
if(aTick == 0 || (tList==null && GT_Proxy.chunkData!=null)){
|
|
||||||
tList = new ArrayList<ChunkPosition>(GT_Proxy.chunkData.keySet());
|
|
||||||
loops = (tList.size()/1200) + 1;
|
|
||||||
// System.out.println("new Pollution loop"+aTick);
|
|
||||||
}
|
}
|
||||||
if(tList!=null && tList.size() > 0){
|
dimensionWisePollution.put(aWorld.provider.dimensionId,this);
|
||||||
int i = 0;
|
}
|
||||||
for(; i < loops ; i++){
|
|
||||||
if(tList.size()>0){
|
public static void onWorldTick(TickEvent.WorldTickEvent aEvent){//called from proxy
|
||||||
ChunkPosition tPos = tList.get(0);
|
//return if pollution disabled
|
||||||
tList.remove(0);
|
if(!GT_Mod.gregtechproxy.mPollution) return;
|
||||||
if(tPos!=null && GT_Proxy.chunkData.containsKey(tPos)){
|
final GT_Pollution pollutionInstance = dimensionWisePollution.get(aEvent.world.provider.dimensionId);
|
||||||
int tPollution = GT_Proxy.chunkData.get(tPos)[1];
|
if(pollutionInstance==null)return;
|
||||||
// System.out.println("process: "+tPos.chunkPosY+" "+tPos.chunkPosX+" "+tPos.chunkPosZ+" "+tPollution);
|
pollutionInstance.tickPollutionInWorld((int)(aEvent.world.getTotalWorldTime()%cycleLen));
|
||||||
//Reduce pollution in chunk
|
}
|
||||||
tPollution = (int)(0.99f*tPollution);
|
|
||||||
tPollution -= 2000;
|
private void tickPollutionInWorld(int aTickID){//called from method above
|
||||||
if(tPollution<=0){tPollution = 0;}
|
//gen data set
|
||||||
//Spread Pollution
|
if(aTickID==0){
|
||||||
if(tPollution>50000){
|
pollutionList = new ArrayList<>(chunkData.keySet());
|
||||||
List<ChunkPosition> tNeighbor = new ArrayList();
|
//set operations per tick
|
||||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX+1, tPos.chunkPosY, tPos.chunkPosZ));
|
if(pollutionList.size()>0) operationsPerTick =(pollutionList.size()/cycleLen);
|
||||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX-1, tPos.chunkPosY, tPos.chunkPosZ));
|
else operationsPerTick=0;//SANity
|
||||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ+1));
|
}
|
||||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ-1));
|
|
||||||
for(ChunkPosition tNPos : tNeighbor){
|
for(int chunksProcessed=0;chunksProcessed<=operationsPerTick;chunksProcessed++){
|
||||||
if(GT_Proxy.chunkData.containsKey(tNPos)){
|
if(pollutionList.size()==0)break;//no more stuff to do
|
||||||
int tNPol = GT_Proxy.chunkData.get(tNPos)[1];
|
ChunkCoordIntPair actualPos=pollutionList.remove(pollutionList.size()-1);//faster
|
||||||
if(tNPol<tPollution && tNPol*12 < tPollution*10){
|
//add default data if missing
|
||||||
int tDiff = tPollution - tNPol;
|
if(!chunkData.containsKey(actualPos)) chunkData.put(actualPos,getDefaultChunkDataOnCreation());
|
||||||
tDiff = tDiff/10;
|
//get pollution
|
||||||
tNPol += tDiff;
|
int tPollution = chunkData.get(actualPos)[GTPOLLUTION];
|
||||||
tPollution -= tDiff;
|
//remove some
|
||||||
GT_Proxy.chunkData.get(tNPos)[1] = tNPol;
|
tPollution = (int)(0.9945f*tPollution);
|
||||||
}
|
//tPollution -= 2000;//This does not really matter...
|
||||||
}else{
|
|
||||||
GT_Utility.getUndergroundOil(aWorld,tNPos.chunkPosX<<4,tNPos.chunkPosZ<<4);
|
if(tPollution<=0) tPollution = 0;//SANity check
|
||||||
|
else if(tPollution>400000){//Spread Pollution
|
||||||
|
|
||||||
|
ChunkCoordIntPair[] tNeighbors = new ChunkCoordIntPair[4];//array is faster
|
||||||
|
tNeighbors[0]=(new ChunkCoordIntPair(actualPos.chunkXPos+1,actualPos.chunkZPos));
|
||||||
|
tNeighbors[1]=(new ChunkCoordIntPair(actualPos.chunkXPos-1,actualPos.chunkZPos));
|
||||||
|
tNeighbors[2]=(new ChunkCoordIntPair(actualPos.chunkXPos,actualPos.chunkZPos+1));
|
||||||
|
tNeighbors[3]=(new ChunkCoordIntPair(actualPos.chunkXPos,actualPos.chunkZPos-1));
|
||||||
|
for(ChunkCoordIntPair neighborPosition : tNeighbors){
|
||||||
|
if(!chunkData.containsKey(neighborPosition)) chunkData.put(actualPos,getDefaultChunkDataOnCreation());
|
||||||
|
|
||||||
|
int neighborPollution = chunkData.get(neighborPosition)[GTPOLLUTION];
|
||||||
|
if(neighborPollution*6 < tPollution*5){//METHEMATICS...
|
||||||
|
int tDiff = tPollution - neighborPollution;
|
||||||
|
tDiff = tDiff/20;
|
||||||
|
neighborPollution = GT_Utility.safeInt((long)neighborPollution+tDiff);//tNPol += tDiff;
|
||||||
|
tPollution -= tDiff;
|
||||||
|
chunkData.get(neighborPosition)[GTPOLLUTION] = neighborPollution;
|
||||||
}
|
}
|
||||||
}}
|
|
||||||
int[] tArray = GT_Proxy.chunkData.get(tPos);
|
|
||||||
tArray[1] = tPollution;
|
|
||||||
GT_Proxy.chunkData.remove(tPos);
|
|
||||||
GT_Proxy.chunkData.put(tPos, tArray);
|
|
||||||
//Create Pollution effects
|
|
||||||
// Smog filter TODO
|
|
||||||
if(tPollution > 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<EntityLivingBase> 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){
|
|
||||||
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;
|
//Create Pollution effects
|
||||||
for(;f<(tPollution/25000);f++){
|
//Smog filter TODO
|
||||||
int x =tPos.chunkPosX<<4+(tRan.nextInt(16));;
|
if(tPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit) {
|
||||||
int y =60 +(-f+tRan.nextInt(f*2+1));
|
AxisAlignedBB chunk = AxisAlignedBB.getBoundingBox(actualPos.chunkXPos << 4, 0, actualPos.chunkZPos << 4, (actualPos.chunkXPos << 4) + 16, 256, (actualPos.chunkZPos << 4) + 16);
|
||||||
int z =tPos.chunkPosZ<<4+(tRan.nextInt(16));
|
List<EntityLivingBase> tEntitys = aWorld.getEntitiesWithinAABB(EntityLivingBase.class, chunk);
|
||||||
damageBlock(x, y, z, tPollution > GT_Mod.gregtechproxy.mPollutionSourRainLimit);
|
for (EntityLivingBase tEnt : tEntitys) {
|
||||||
}}}}
|
if (!GT_Utility.isWearingFullGasHazmat(tEnt)) {
|
||||||
|
switch (tRan.nextInt(3)) {
|
||||||
|
default:
|
||||||
|
tEnt.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, Math.min(tPollution / 1000, 1000), tPollution / 400000));
|
||||||
|
case 1:
|
||||||
|
tEnt.addPotionEffect(new PotionEffect(Potion.weakness.id, Math.min(tPollution / 1000, 1000), tPollution / 400000));
|
||||||
|
case 2:
|
||||||
|
tEnt.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, Math.min(tPollution / 1000, 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<EntityLiving> tEntitys = aWorld.getEntitiesWithinAABB(EntityLiving.class, chunk);
|
||||||
|
for (EntityLivingBase tEnt : tEntitys) {
|
||||||
|
if (!GT_Utility.isWearingFullGasHazmat(tEnt)) {
|
||||||
|
switch (tRan.nextInt(4)) {
|
||||||
|
default:
|
||||||
|
tEnt.addPotionEffect(new PotionEffect(Potion.hunger.id, tPollution / 500000));
|
||||||
|
case 1:
|
||||||
|
tEnt.addPotionEffect(new PotionEffect(Potion.confusion.id, Math.min(tPollution / 2000, 1000), 1));
|
||||||
|
case 2:
|
||||||
|
tEnt.addPotionEffect(new PotionEffect(Potion.poison.id, Math.min(tPollution / 4000, 1000), tPollution / 500000));
|
||||||
|
case 3:
|
||||||
|
tEnt.addPotionEffect(new PotionEffect(Potion.blindness.id, Math.min(tPollution / 2000, 1000), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// killing plants
|
||||||
|
if (tPollution > GT_Mod.gregtechproxy.mPollutionVegetationLimit) {
|
||||||
|
int f = 20;
|
||||||
|
for (; f < (tPollution / 25000); f++) {
|
||||||
|
int x = (actualPos.chunkXPos << 4) + tRan.nextInt(16);
|
||||||
|
int y = 60 + (-f + tRan.nextInt(f * 2 + 1));
|
||||||
|
int z = (actualPos.chunkZPos << 4) + tRan.nextInt(16);
|
||||||
|
damageBlock(aWorld, x, y, z, tPollution > GT_Mod.gregtechproxy.mPollutionSourRainLimit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
//Write new pollution to Hashmap !!!
|
||||||
|
chunkData.get(actualPos)[GTPOLLUTION] = tPollution;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void damageBlock(int x, int y, int z, boolean sourRain){
|
private static void damageBlock(World world, int x, int y, int z, boolean sourRain){
|
||||||
World world = DimensionManager.getWorld(0);
|
|
||||||
if (world.isRemote) return;
|
if (world.isRemote) return;
|
||||||
Block tBlock = world.getBlock(x, y, z);
|
Block tBlock = world.getBlock(x, y, z);
|
||||||
int tMeta = world.getBlockMetadata(x, y, z);
|
int tMeta = world.getBlockMetadata(x, y, z);
|
||||||
|
@ -187,24 +230,31 @@ public class GT_Pollution {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add aWorld to Save Pollution
|
public static void addPollution(IGregTechTileEntity te, int aPollution){
|
||||||
public static void addPollution(World aWorld, ChunkPosition aPos, int aPollution){
|
System.out.println(te.getWorld().provider.dimensionId+" "+te.getXCoord()+" "+te.getZCoord());
|
||||||
if(!GT_Mod.gregtechproxy.mPollution)return;
|
addPollution(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()), aPollution);
|
||||||
try{
|
|
||||||
ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleCoordinates(aPos.chunkPosX,16), aWorld.provider.dimensionId, GT_Utility.getScaleCoordinates(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[3];
|
|
||||||
if(GT_Proxy.chunkData.containsKey(tPos)){
|
|
||||||
tData = GT_Proxy.chunkData.get(tPos);
|
|
||||||
if(tData.length>1){
|
|
||||||
tData[1] += aPollution;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
tData[1] += aPollution;
|
|
||||||
GT_Proxy.chunkData.put(tPos, tData);
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static void addPollution(Chunk ch, int aPollution){
|
||||||
|
if(!GT_Mod.gregtechproxy.mPollution)return;
|
||||||
|
HashMap<ChunkCoordIntPair,int[]> dataMap=dimensionWiseChunkData.get(ch.worldObj.provider.dimensionId);
|
||||||
|
if(dataMap==null){
|
||||||
|
dataMap=new HashMap<>(1024);
|
||||||
|
dimensionWiseChunkData.put(ch.worldObj.provider.dimensionId,dataMap);
|
||||||
|
}
|
||||||
|
if(dataMap.get(ch.getChunkCoordIntPair())==null)
|
||||||
|
dataMap.put(ch.getChunkCoordIntPair(),getDefaultChunkDataOnCreation());
|
||||||
|
dataMap.get(ch.getChunkCoordIntPair())[GTPOLLUTION]+=aPollution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPollution(IGregTechTileEntity te){
|
||||||
|
return getPollution(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPollution(Chunk ch){
|
||||||
|
if(!GT_Mod.gregtechproxy.mPollution)return 0;
|
||||||
|
HashMap<ChunkCoordIntPair,int[]> dataMap=dimensionWiseChunkData.get(ch.worldObj.provider.dimensionId);
|
||||||
|
if(dataMap==null || dataMap.get(ch.getChunkCoordIntPair())==null) return 0;
|
||||||
|
return dataMap.get(ch.getChunkCoordIntPair())[GTPOLLUTION];
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,8 @@ import cpw.mods.fml.common.Loader;
|
||||||
import cpw.mods.fml.common.ModContainer;
|
import cpw.mods.fml.common.ModContainer;
|
||||||
import cpw.mods.fml.common.ProgressManager;
|
import cpw.mods.fml.common.ProgressManager;
|
||||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||||
|
import cpw.mods.fml.common.eventhandler.EventBus;
|
||||||
|
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||||
|
@ -55,10 +57,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
|
import net.minecraft.world.ChunkCoordIntPair;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldSettings.GameType;
|
import net.minecraft.world.WorldSettings.GameType;
|
||||||
import net.minecraft.world.gen.feature.WorldGenMinable;
|
import net.minecraft.world.gen.feature.WorldGenMinable;
|
||||||
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.ForgeEventFactory;
|
import net.minecraftforge.event.ForgeEventFactory;
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
|
@ -69,6 +73,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.event.terraingen.OreGenEvent;
|
import net.minecraftforge.event.terraingen.OreGenEvent;
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
import net.minecraftforge.event.world.ChunkDataEvent;
|
import net.minecraftforge.event.world.ChunkDataEvent;
|
||||||
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
@ -581,6 +586,9 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {e.printStackTrace(GT_Log.err);}
|
} catch (Throwable e) {e.printStackTrace(GT_Log.err);}
|
||||||
|
|
||||||
|
dimensionWiseChunkData.clear();//!!! IMPORTANT for map switching...
|
||||||
|
dimensionWisePollution.clear();//!!! IMPORTANT for map switching...
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServerStarted() {
|
public void onServerStarted() {
|
||||||
|
@ -1246,8 +1254,8 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(aEvent.world.provider.dimensionId==0)
|
|
||||||
GT_Pollution.onWorldTick(aEvent.world, (int) (aEvent.world.getTotalWorldTime() % 1200));
|
GT_Pollution.onWorldTick(aEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1700,48 +1708,91 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
|
||||||
ProgressManager.pop(progressBar);
|
ProgressManager.pop(progressBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final HashMap<ChunkPosition, int[]> chunkData = new HashMap<ChunkPosition, int[]>(5000);
|
public static final HashMap<Integer,HashMap<ChunkCoordIntPair,int []>> dimensionWiseChunkData = new HashMap<>(16);//stores chunk data that is loaded/saved
|
||||||
|
public static final HashMap<Integer,GT_Pollution> dimensionWisePollution = new HashMap<>(16);//stores GT_Polluttors objects
|
||||||
|
public static final byte GTOIL=3,GTOILFLUID=2,GTPOLLUTION=1,GTMETADATA=0,NOT_LOADED=0,LOADED=1;//consts
|
||||||
|
//@Deprecated
|
||||||
|
//public static final HashMap<ChunkPosition, int[]> chunkData = new HashMap<>(0);
|
||||||
|
|
||||||
@SubscribeEvent
|
private static final byte oilVer=(byte)20;//non zero plz
|
||||||
public void handleChunkSaveEvent(ChunkDataEvent.Save event)
|
|
||||||
{
|
//TO get default's fast
|
||||||
ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,event.getChunk().worldObj.provider.dimensionId,event.getChunk().zPosition);
|
public static int[] getDefaultChunkDataOnCreation(){
|
||||||
if(chunkData.containsKey(tPos)){
|
return new int[]{NOT_LOADED,0,-1,-1};
|
||||||
int[] tInts = chunkData.get(tPos);
|
}
|
||||||
if(tInts.length>0){event.getData().setInteger("GTOIL", tInts[0]);}
|
public static int[] getDefaultChunkDataOnLoad(){
|
||||||
if(tInts.length>1){event.getData().setInteger("GTPOLLUTION", tInts[1]);}
|
return new int[]{LOADED,0,-1,-1};
|
||||||
if(tInts.length>2){event.getData().setInteger("GTOILFLUID", tInts[2]);}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void handleChunkLoadEvent(ChunkDataEvent.Load event)
|
public void handleChunkSaveEvent(ChunkDataEvent.Save event) {//ALWAYS SAVE FROM THE HASH MAP DATA
|
||||||
{
|
HashMap<ChunkCoordIntPair,int []> chunkData=dimensionWiseChunkData.get(event.world.provider.dimensionId);
|
||||||
int tOil = 0;
|
if(chunkData==null) return;//no dim info stored
|
||||||
int tOilFluid = 0;
|
|
||||||
int tPollution = 0;
|
|
||||||
|
|
||||||
ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,event.getChunk().worldObj.provider.dimensionId,event.getChunk().zPosition);
|
int[] tInts = chunkData.get(event.getChunk().getChunkCoordIntPair());
|
||||||
int[] tData = new int[0];
|
if(tInts==null) return;//no chunk data stored
|
||||||
if(chunkData.containsKey(tPos)){
|
//assuming len of this array 4
|
||||||
tData = chunkData.get(tPos);
|
if(tInts[3]>=0)event.getData().setInteger("GTOIL", tInts[GTOIL]);
|
||||||
chunkData.remove(tPos);
|
else event.getData().removeTag("GTOIL");
|
||||||
if(tData.length>0)
|
if(tInts[2]>=0)event.getData().setInteger("GTOILFLUID", tInts[GTOILFLUID]);
|
||||||
tOil = tData[0];
|
else event.getData().removeTag("GTOILFLUID");
|
||||||
if(tData.length>1)
|
if(tInts[1]>0)event.getData().setInteger("GTPOLLUTION", tInts[GTPOLLUTION]);
|
||||||
tPollution = tData[1];
|
else event.getData().removeTag("GTPOLLUTION");
|
||||||
if(tData.length>2)
|
event.getData().setByte("GTOILVER", oilVer);//version mark
|
||||||
tOilFluid = tData[2];
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void handleChunkLoadEvent(ChunkDataEvent.Load event) {
|
||||||
|
final int worldID=event.world.provider.dimensionId;
|
||||||
|
HashMap<ChunkCoordIntPair, int[]> chunkData = dimensionWiseChunkData.get(worldID);
|
||||||
|
if (chunkData == null){
|
||||||
|
chunkData=new HashMap<>(1024);
|
||||||
|
dimensionWiseChunkData.put(worldID, chunkData);
|
||||||
}
|
}
|
||||||
|
if (dimensionWisePollution.get(worldID) == null)
|
||||||
|
dimensionWisePollution.put(worldID, new GT_Pollution(event.world));
|
||||||
|
|
||||||
if(tOil==0&&event.getData().hasKey("GTOIL"))
|
int[] tInts = chunkData.get(event.getChunk().getChunkCoordIntPair());
|
||||||
tOil = event.getData().getInteger("GTOIL");
|
if (tInts == null) {
|
||||||
if(tPollution==0&&event.getData().hasKey("GTPOLLUTION"))
|
//NOT LOADED and NOT PROCESSED by pollution algorithms
|
||||||
tPollution = event.getData().getInteger("GTPOLLUTION");
|
//regular load
|
||||||
if(tOilFluid==0&&event.getData().hasKey("GTOILFLUID"))
|
tInts = getDefaultChunkDataOnLoad();
|
||||||
tOilFluid = event.getData().getInteger("GTOILFLUID");
|
|
||||||
|
|
||||||
chunkData.put(tPos, new int[]{tOil,tPollution,tOilFluid});
|
if (event.getData().getByte("GTOILVER") == oilVer) {
|
||||||
|
if (event.getData().hasKey("GTOIL"))
|
||||||
|
tInts[GTOIL] = event.getData().getInteger("GTOIL");
|
||||||
|
if (event.getData().hasKey("GTOILFLUID"))
|
||||||
|
tInts[GTOILFLUID] = event.getData().getInteger("GTOILFLUID");
|
||||||
|
}
|
||||||
|
|
||||||
|
tInts[GTPOLLUTION] = event.getData().getInteger("GTPOLLUTION");//Defaults to 0
|
||||||
|
|
||||||
|
//store in HASH MAP if has useful data
|
||||||
|
if (tInts[GTPOLLUTION] > 0 || tInts[GTOIL] >= 0 || tInts[GTOILFLUID] >= 0)
|
||||||
|
chunkData.put(event.getChunk().getChunkCoordIntPair(), tInts);
|
||||||
|
} else if (tInts[GTMETADATA] == NOT_LOADED) {//was NOT loaded from chunk save game data
|
||||||
|
//NOT LOADED but generated
|
||||||
|
//append load
|
||||||
|
if (event.getData().getByte("GTOILVER") == oilVer) {
|
||||||
|
if (tInts[GTOIL] < 0 && event.getData().hasKey("GTOIL"))//if was not yet initialized
|
||||||
|
tInts[GTOIL] = event.getData().getInteger("GTOIL");
|
||||||
|
|
||||||
|
if (tInts[GTOILFLUID] < 0 && event.getData().hasKey("GTOILFLUID"))//if was not yet initialized
|
||||||
|
tInts[GTOILFLUID] = event.getData().getInteger("GTOILFLUID");
|
||||||
|
} else {
|
||||||
|
tInts[GTOIL] = -1;
|
||||||
|
tInts[GTOILFLUID] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tInts[GTPOLLUTION] += event.getData().getInteger("GTPOLLUTION");//Defaults to 0, add stored pollution to data
|
||||||
|
tInts[GTMETADATA] = LOADED;//mark as = loaded
|
||||||
|
//store in HASHMAP
|
||||||
|
|
||||||
|
chunkData.put(event.getChunk().getChunkCoordIntPair(), tInts);
|
||||||
|
}//else if(tInts[0]==1){
|
||||||
|
////Already loaded chunk data
|
||||||
|
////DO NOTHING - this chunk data was already loaded and stored in hash map
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class OreDictEventContainer {
|
public static class OreDictEventContainer {
|
||||||
|
|
96
src/main/java/gregtech/common/GT_UndergroundOil.java
Normal file
96
src/main/java/gregtech/common/GT_UndergroundOil.java
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
package gregtech.common;
|
||||||
|
|
||||||
|
import gregtech.GT_Mod;
|
||||||
|
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||||
|
import gregtech.api.objects.GT_UO_Fluid;
|
||||||
|
import gregtech.api.objects.XSTR;
|
||||||
|
import gregtech.common.GT_Proxy;
|
||||||
|
import net.minecraft.world.ChunkCoordIntPair;
|
||||||
|
import net.minecraft.world.ChunkPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import static gregtech.api.util.GT_Utility.getScaleCoordinates;
|
||||||
|
import static gregtech.common.GT_Proxy.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Tec on 29.04.2017.
|
||||||
|
*/
|
||||||
|
public class GT_UndergroundOil {
|
||||||
|
|
||||||
|
public static FluidStack undergroundOil(IGregTechTileEntity te,float drainSpeedCoefficient){
|
||||||
|
return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),drainSpeedCoefficient);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns whole content for information purposes -> when drainSpeedCoeff < 0
|
||||||
|
//Else returns extracted fluidStack if amount > 0, or null otherwise
|
||||||
|
public static FluidStack undergroundOil(Chunk chunk, float drainSpeedCoefficient) {
|
||||||
|
if (GT_Mod.gregtechproxy.mUndergroundOil.CheckBlackList(chunk.worldObj.provider.dimensionId)) return null;
|
||||||
|
World aWorld = chunk.worldObj;
|
||||||
|
|
||||||
|
//Read hash map
|
||||||
|
HashMap<ChunkCoordIntPair, int[]> chunkData = dimensionWiseChunkData.get(aWorld.provider.dimensionId);
|
||||||
|
if(chunkData==null){
|
||||||
|
chunkData=new HashMap<>(1024);
|
||||||
|
dimensionWiseChunkData.put(aWorld.provider.dimensionId,chunkData);
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] tInts = chunkData.get(chunk.getChunkCoordIntPair());
|
||||||
|
|
||||||
|
if(tInts==null) tInts=getDefaultChunkDataOnCreation();//init if null
|
||||||
|
else if(tInts[GTOIL]==0){
|
||||||
|
//can return 0 amount stack for info :D
|
||||||
|
return drainSpeedCoefficient>=0 ? null : new FluidStack(FluidRegistry.getFluid(tInts[GTOILFLUID]),0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GEN IT TO GET OBJECT...
|
||||||
|
XSTR tRandom = new XSTR(aWorld.getSeed() + aWorld.provider.dimensionId * 2 +
|
||||||
|
(chunk.getChunkCoordIntPair().chunkXPos>>3) +
|
||||||
|
8267 * (chunk.getChunkCoordIntPair().chunkZPos>>3));
|
||||||
|
GT_UO_Fluid uoFluid = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).getRandomFluid(tRandom);
|
||||||
|
|
||||||
|
//Fluid stack holder
|
||||||
|
FluidStack fluidInChunk;
|
||||||
|
|
||||||
|
//Set fluidstack from uoFluid
|
||||||
|
if (uoFluid == null || uoFluid.getFluid()==null){
|
||||||
|
tInts[GTOILFLUID]=Integer.MAX_VALUE;//null fluid pointer... kindof
|
||||||
|
tInts[GTOIL]=0;
|
||||||
|
chunkData.put(chunk.getChunkCoordIntPair(),tInts);//update hash map
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
if(tInts[GTOILFLUID]== uoFluid.getFluid().getID()){//if stored fluid matches uoFluid
|
||||||
|
fluidInChunk = new FluidStack(uoFluid.getFluid(),tInts[GTOIL]);
|
||||||
|
}else{
|
||||||
|
fluidInChunk = new FluidStack(uoFluid.getFluid(), uoFluid.getRandomAmount(tRandom));
|
||||||
|
tRandom=new XSTR();
|
||||||
|
fluidInChunk.amount=(int)((float)fluidInChunk.amount*(0.75f+(tRandom.nextFloat()/2f)));//Randomly change amounts by +/- 25%
|
||||||
|
}
|
||||||
|
tInts[GTOIL]=fluidInChunk.amount;
|
||||||
|
tInts[GTOILFLUID]=fluidInChunk.getFluidID();
|
||||||
|
}
|
||||||
|
|
||||||
|
//do stuff on it if needed
|
||||||
|
if(drainSpeedCoefficient>=0) {
|
||||||
|
int actualExtractionSpeed=(int)(uoFluid.DecreasePerOperationAmountInBuckets*1000*drainSpeedCoefficient);
|
||||||
|
if(fluidInChunk.amount>actualExtractionSpeed) {
|
||||||
|
fluidInChunk.amount=actualExtractionSpeed;//give appropriate amount
|
||||||
|
tInts[GTOIL]-=actualExtractionSpeed;//diminish amount
|
||||||
|
}else if(fluidInChunk.amount>0) {
|
||||||
|
//fluidInChunk.amount= the same amount... going to return this
|
||||||
|
tInts[GTOIL]=0;
|
||||||
|
}else{
|
||||||
|
fluidInChunk=null;
|
||||||
|
tInts[GTOIL]=0;//just to be on safe side...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chunkData.put(chunk.getChunkCoordIntPair(),tInts);//update hash map
|
||||||
|
return fluidInChunk;
|
||||||
|
}
|
||||||
|
}
|
|
@ -148,7 +148,7 @@ public class GT_MetaTileEntity_Boiler_Bronze
|
||||||
this.mTemperature += 1;
|
this.mTemperature += 1;
|
||||||
}
|
}
|
||||||
if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) {
|
if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) {
|
||||||
GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 20);
|
GT_Pollution.addPollution(getBaseMetaTileEntity(), 20);
|
||||||
}
|
}
|
||||||
aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
|
aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class GT_MetaTileEntity_Boiler_Lava
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) {
|
if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) {
|
||||||
GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 20);
|
GT_Pollution.addPollution(getBaseMetaTileEntity(), 20);
|
||||||
}
|
}
|
||||||
aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
|
aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class GT_MetaTileEntity_Boiler_Steel
|
||||||
this.mTemperature += 1;
|
this.mTemperature += 1;
|
||||||
}
|
}
|
||||||
if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) {
|
if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) {
|
||||||
GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 20);
|
GT_Pollution.addPollution(getBaseMetaTileEntity(), 30);
|
||||||
}
|
}
|
||||||
aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
|
aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import gregtech.api.objects.ItemData;
|
||||||
import gregtech.api.util.GT_ModHandler;
|
import gregtech.api.util.GT_ModHandler;
|
||||||
import gregtech.api.util.GT_OreDictUnificator;
|
import gregtech.api.util.GT_OreDictUnificator;
|
||||||
import gregtech.api.util.GT_Utility;
|
import gregtech.api.util.GT_Utility;
|
||||||
|
import gregtech.common.GT_UndergroundOil;
|
||||||
import gregtech.common.blocks.GT_Block_Ores_Abstract;
|
import gregtech.common.blocks.GT_Block_Ores_Abstract;
|
||||||
import gregtech.common.blocks.GT_TileEntity_Ores;
|
import gregtech.common.blocks.GT_TileEntity_Ores;
|
||||||
import ic2.core.Ic2Items;
|
import ic2.core.Ic2Items;
|
||||||
|
@ -148,7 +149,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
|
||||||
for (int z = tLeftZBound; z <= tRightZBound; ++z)
|
for (int z = tLeftZBound; z <= tRightZBound; ++z)
|
||||||
{
|
{
|
||||||
ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleCoordinates(x*16,96), 0, GT_Utility.getScaleCoordinates(z*16,96));
|
ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleCoordinates(x*16,96), 0, GT_Utility.getScaleCoordinates(z*16,96));
|
||||||
FluidStack tFluid = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), x*16, z*16);
|
FluidStack tFluid = GT_UndergroundOil.undergroundOil(getBaseMetaTileEntity(),-1);
|
||||||
if (tFluid != null)
|
if (tFluid != null)
|
||||||
if (tFluids.containsKey(tPos))
|
if (tFluids.containsKey(tPos))
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@ import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class GT_MetaTileEntity_BronzeBlastFurnace
|
public class GT_MetaTileEntity_BronzeBlastFurnace
|
||||||
|
@ -187,10 +188,6 @@ public class GT_MetaTileEntity_BronzeBlastFurnace
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
|
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
|
||||||
if ((aBaseMetaTileEntity.isClientSide()) &&
|
|
||||||
(aBaseMetaTileEntity.isActive())) {
|
|
||||||
aBaseMetaTileEntity.getWorld().spawnParticle("largesmoke", aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + (new XSTR()).nextFloat(), aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + (new XSTR()).nextFloat(), 0.0D, 0.3D, 0.0D);
|
|
||||||
}
|
|
||||||
if (aBaseMetaTileEntity.isServerSide()) {
|
if (aBaseMetaTileEntity.isServerSide()) {
|
||||||
if (this.mUpdate-- == 0) {
|
if (this.mUpdate-- == 0) {
|
||||||
this.mMachine = checkMachine();
|
this.mMachine = checkMachine();
|
||||||
|
@ -210,7 +207,7 @@ public class GT_MetaTileEntity_BronzeBlastFurnace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.mMaxProgresstime>0 && (aTimer % 20L == 0L)){
|
if(this.mMaxProgresstime>0 && (aTimer % 20L == 0L)){
|
||||||
GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 50);
|
GT_Pollution.addPollution(getBaseMetaTileEntity(), 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine));
|
aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine));
|
||||||
|
@ -233,8 +230,20 @@ public class GT_MetaTileEntity_BronzeBlastFurnace
|
||||||
this.mUpdate = 1;
|
this.mUpdate = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else if(aBaseMetaTileEntity.isActive()){
|
||||||
|
World aWorld=aBaseMetaTileEntity.getWorld();
|
||||||
|
double xPos=aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1);
|
||||||
|
double yPos=aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1)+0.05F;
|
||||||
|
double zPos=aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1);
|
||||||
|
XSTR floatGen=new XSTR();
|
||||||
|
aWorld.spawnParticle("largesmoke", xPos + floatGen.nextFloat(), yPos, zPos + floatGen.nextFloat(), 0.0D, 0.3D, 0.0D);
|
||||||
|
//Pollution particles intensify
|
||||||
|
if(GT_Pollution.getPollution(getBaseMetaTileEntity())>GT_Mod.gregtechproxy.mPollutionSmogLimit){
|
||||||
|
aWorld.spawnParticle("largesmoke", xPos + floatGen.nextFloat(), yPos, zPos + floatGen.nextFloat(), 0.0D, 0.45D, 0.0D);
|
||||||
|
aWorld.spawnParticle("largesmoke", xPos + floatGen.nextFloat(), yPos, zPos + floatGen.nextFloat(), 0.0D, 0.6D, 0.0D);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOutputProducts() {
|
private void addOutputProducts() {
|
||||||
if (this.mOutputItem1 != null) {
|
if (this.mOutputItem1 != null) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock
|
||||||
this.mEfficiency = 10000;
|
this.mEfficiency = 10000;
|
||||||
this.mEfficiencyIncrease = 10000;
|
this.mEfficiencyIncrease = 10000;
|
||||||
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
|
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
|
||||||
GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), mMaxProgresstime*5);
|
GT_Pollution.addPollution(getBaseMetaTileEntity(), mMaxProgresstime*5);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.mEfficiency = 0;
|
this.mEfficiency = 0;
|
||||||
|
|
|
@ -18,6 +18,8 @@ import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static gregtech.common.GT_UndergroundOil.undergroundOil;
|
||||||
|
|
||||||
public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase {
|
public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase {
|
||||||
|
|
||||||
private boolean completedCycle = false;
|
private boolean completedCycle = false;
|
||||||
|
@ -73,12 +75,13 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluidStack tFluid = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord(), true);
|
FluidStack tFluid = undergroundOil(getBaseMetaTileEntity(),.5F+(getInputTier()*.25F));
|
||||||
if (tFluid == null) {
|
if (tFluid == null) {
|
||||||
stopMachine();
|
stopMachine();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getYOfPumpHead() > 0 && getBaseMetaTileEntity().getBlockOffset(ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX, getYOfPumpHead() - 1 - getBaseMetaTileEntity().getYCoord(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ) != Blocks.bedrock) {
|
if (getYOfPumpHead() > 0 && getBaseMetaTileEntity().getBlockOffset(ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX, getYOfPumpHead() - 1 - getBaseMetaTileEntity().getYCoord(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ) != Blocks.bedrock) {
|
||||||
|
|
||||||
if (completedCycle) {
|
if (completedCycle) {
|
||||||
moveOneDown();
|
moveOneDown();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue