Pollution configs and first effects
This commit is contained in:
parent
16fb901529
commit
7074a513ab
4 changed files with 113 additions and 16 deletions
|
@ -235,6 +235,11 @@ public class GT_Mod implements IGT_Mod {
|
|||
gregtechproxy.mArcSmeltIntoAnnealed = tMainConfig.get(aTextGeneral, "ArcSmeltIntoAnnealedWrought", true).getBoolean(true);
|
||||
gregtechproxy.mMagneticraftRecipes = tMainConfig.get(aTextGeneral, "EnableMagneticraftSupport", true).getBoolean(true);
|
||||
gregtechproxy.mMagneticraftBonusOutputPercent = tMainConfig.get(aTextGeneral, "MagneticraftBonusOutputPercent", 100.0f).getDouble();
|
||||
gregtechproxy.mPollution = tMainConfig.get("Pollution", "EnablePollution", true).getBoolean(true);
|
||||
gregtechproxy.mPollutionSmogLimit = tMainConfig.get("Pollution", "SmogLimit", 500000).getInt(500000);
|
||||
gregtechproxy.mPollutionPoisonLimit = tMainConfig.get("Pollution", "PoisonLimit", 750000).getInt(750000);
|
||||
gregtechproxy.mPollutionVegetationLimit = tMainConfig.get("Pollution", "VegetationLimit", 1000000).getInt(1000000);
|
||||
gregtechproxy.mPollutionSourRainLimit = tMainConfig.get("Pollution", "SourRainLimit", 2000000).getInt(2000000);
|
||||
|
||||
GregTech_API.mOutputRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "OutputRF", true);
|
||||
GregTech_API.mInputRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "InputRF", false);
|
||||
|
|
|
@ -1742,7 +1742,7 @@ public class GT_Utility {
|
|||
FluidStack tFluid = getUndergroundOil(aWorld, aX, aZ);
|
||||
tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName());
|
||||
}
|
||||
if(aPlayer.capabilities.isCreativeMode){
|
||||
// if(aPlayer.capabilities.isCreativeMode){
|
||||
ChunkPosition tPos = new ChunkPosition(aX/16, 1, aZ/16);
|
||||
if(GT_Proxy.chunkData.containsKey(tPos)){
|
||||
int[] tPollution = GT_Proxy.chunkData.get(tPos);
|
||||
|
@ -1752,7 +1752,7 @@ public class GT_Utility {
|
|||
tList.add("No Pollution in Chunk");
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
try {
|
||||
if (tBlock instanceof IDebugableBlock) {
|
||||
|
|
|
@ -3,21 +3,35 @@
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import gregtech.GT_Mod;
|
||||
import gregtech.api.objects.XSTR;
|
||||
import gregtech.api.util.GT_Utility;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldManager;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
public class GT_Pollution {
|
||||
|
||||
|
||||
static List<ChunkPosition> tList = null;
|
||||
static int loops = 1;
|
||||
static XSTR tRan = new XSTR();
|
||||
|
||||
public static void onWorldTick(int aTick){
|
||||
if(!GT_Mod.gregtechproxy.mPollution)return;
|
||||
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){
|
||||
int i = 0;
|
||||
|
@ -34,14 +48,14 @@ public class GT_Pollution {
|
|||
//Spread Pollution
|
||||
if(tPollution>50000){
|
||||
List<ChunkPosition> tNeighbor = new ArrayList();
|
||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX+1, 1, tPos.chunkPosZ+1));
|
||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX+1, 1, tPos.chunkPosZ-1));
|
||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX-1, 1, tPos.chunkPosZ+1));
|
||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX-1, 1, tPos.chunkPosZ-1));
|
||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX+1, 1, tPos.chunkPosZ));
|
||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX-1, 1, tPos.chunkPosZ));
|
||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX, 1, tPos.chunkPosZ+1));
|
||||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX, 1, tPos.chunkPosZ-1));
|
||||
for(ChunkPosition tNPos : tNeighbor){
|
||||
if(GT_Proxy.chunkData.containsKey(tNPos)){
|
||||
int tNPol = GT_Proxy.chunkData.get(tNPos)[1];
|
||||
if(tNPol<tPollution){
|
||||
if(tNPol<tPollution && tNPol*120 < tPollution*100){
|
||||
int tDiff = tPollution - tNPol;
|
||||
tDiff = tDiff/10;
|
||||
tNPol += tDiff;
|
||||
|
@ -57,14 +71,86 @@ public class GT_Pollution {
|
|||
GT_Proxy.chunkData.remove(tPos);
|
||||
GT_Proxy.chunkData.put(tPos, tArray);
|
||||
//Create Pollution effects
|
||||
|
||||
// Smog filter TODO
|
||||
if(tPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit){
|
||||
|
||||
// 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 = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABB(EntityLiving.class, chunk);
|
||||
for(EntityLiving tEnt : tEntitys){
|
||||
if(tRan.nextInt(tPollution/25000) > 20){
|
||||
tEnt.addPotionEffect(new PotionEffect(Potion.poison.id, tPollution/25000, 1));
|
||||
}
|
||||
}
|
||||
// killing plants
|
||||
if(tPollution > GT_Mod.gregtechproxy.mPollutionVegetationLimit){
|
||||
int f = 20;
|
||||
for(;f<(tPollution/25000);f++){
|
||||
int x =tPos.chunkPosX*16+(tRan.nextInt(16));;
|
||||
int y =60 +(-f+tRan.nextInt(f*2+1));
|
||||
int z =tPos.chunkPosZ*16+(tRan.nextInt(16));
|
||||
damageBlock(x, y, z, tPollution > GT_Mod.gregtechproxy.mPollutionSourRainLimit);
|
||||
}}}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void damageBlock(int x, int y, int z, boolean sourRain){
|
||||
World world = DimensionManager.getWorld(0);
|
||||
if (world.isRemote) return;
|
||||
Block tBlock = world.getBlock(x, y, z);
|
||||
int tMeta = world.getBlockMetadata(x, y, z);
|
||||
if (tBlock == Blocks.air || tBlock == Blocks.stone || tBlock == Blocks.sand|| tBlock == Blocks.deadbush)return;
|
||||
|
||||
if (tBlock == Blocks.leaves || tBlock == Blocks.leaves2 || tBlock.getMaterial() == Material.leaves)
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (tBlock == Blocks.reeds) {
|
||||
tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
if (tBlock == Blocks.tallgrass)
|
||||
world.setBlock(x, y, z, Blocks.deadbush);
|
||||
if (tBlock == Blocks.vine) {
|
||||
tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
if (tBlock == Blocks.waterlily || tBlock == Blocks.wheat || tBlock == Blocks.cactus ||
|
||||
tBlock.getMaterial() == Material.cactus || tBlock == Blocks.melon_block || tBlock == Blocks.melon_stem) {
|
||||
tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
if (tBlock == Blocks.red_flower || tBlock == Blocks.yellow_flower || tBlock == Blocks.carrots ||
|
||||
tBlock == Blocks.potatoes || tBlock == Blocks.pumpkin || tBlock == Blocks.pumpkin_stem) {
|
||||
tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
if (tBlock == Blocks.sapling || tBlock.getMaterial() == Material.plants)
|
||||
world.setBlock(x, y, z, Blocks.deadbush);
|
||||
if (tBlock == Blocks.cocoa) {
|
||||
tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
if (tBlock == Blocks.mossy_cobblestone)
|
||||
world.setBlock(x, y, z, Blocks.cobblestone);
|
||||
if (tBlock == Blocks.grass || tBlock.getMaterial() == Material.grass )
|
||||
world.setBlock(x, y, z, Blocks.dirt);
|
||||
if(tBlock == Blocks.farmland || tBlock == Blocks.dirt){
|
||||
world.setBlock(x, y, z, Blocks.sand);
|
||||
}
|
||||
|
||||
if(sourRain && world.isRaining() && (tBlock == Blocks.stone || tBlock == Blocks.gravel || tBlock == Blocks.cobblestone) &&
|
||||
world.getBlock(x, y+1, z) == Blocks.air && world.canBlockSeeTheSky(x, y, z)){
|
||||
if(tBlock == Blocks.stone){world.setBlock(x, y, z, Blocks.cobblestone); }
|
||||
else if(tBlock == Blocks.cobblestone){world.setBlock(x, y, z, Blocks.gravel); }
|
||||
else if(tBlock == Blocks.gravel){world.setBlock(x, y, z, Blocks.sand); }
|
||||
}
|
||||
}
|
||||
|
||||
public static void addPollution(ChunkPosition aPos, int aPollution){
|
||||
if(!GT_Mod.gregtechproxy.mPollution)return;
|
||||
try{
|
||||
ChunkPosition tPos = new ChunkPosition(aPos.chunkPosX/16, 1, aPos.chunkPosZ/16);
|
||||
// System.out.println("add pollution x: "+ tPos.chunkPosX +" z: " + tPos.chunkPosZ +" poll: "+aPollution);
|
||||
|
|
|
@ -149,24 +149,29 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
|
|||
public boolean mAE2Integration = true;
|
||||
public boolean mArcSmeltIntoAnnealed = true;
|
||||
public boolean mMagneticraftRecipes = true;
|
||||
private boolean isFirstServerWorldTick = true;
|
||||
private boolean mOreDictActivated = false;
|
||||
public boolean mChangeHarvestLevels=false;
|
||||
public boolean mNerfedCombs = true;
|
||||
public boolean mGTBees = true;
|
||||
public boolean mHideUnusedOres = true;
|
||||
public boolean mHideRecyclingRecipes = true;
|
||||
public boolean mPollution = true;
|
||||
public int mSkeletonsShootGTArrows = 16;
|
||||
public int mMaxEqualEntitiesAtOneSpot = 3;
|
||||
public int mFlintChance = 30;
|
||||
public int mItemDespawnTime = 6000;
|
||||
public int mUpgradeCount = 4;
|
||||
public boolean mGTBees = true;
|
||||
private World mUniverse = null;
|
||||
private boolean isFirstServerWorldTick = true;
|
||||
private boolean mOreDictActivated = false;
|
||||
public int[] mHarvestLevel= new int[1000];
|
||||
public int mGraniteHavestLevel=3;
|
||||
public int mMaxHarvestLevel=7;
|
||||
public boolean mChangeHarvestLevels=false;
|
||||
public boolean mNerfedCombs = true;
|
||||
public int mWireHeatingTicks = 4;
|
||||
public boolean mHideUnusedOres = true;
|
||||
public boolean mHideRecyclingRecipes = true;
|
||||
public int mPollutionSmogLimit = 500000;
|
||||
public int mPollutionPoisonLimit = 750000;
|
||||
public int mPollutionVegetationLimit = 1000000;
|
||||
public int mPollutionSourRainLimit = 2000000;
|
||||
public double mMagneticraftBonusOutputPercent = 100.0d;
|
||||
private World mUniverse = null;
|
||||
private final String aTextThermalExpansion = "ThermalExpansion";
|
||||
private final String aTextRailcraft = "Railcraft";
|
||||
private final String aTextTwilightForest = "TwilightForest";
|
||||
|
@ -1410,6 +1415,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(aEvent.world.provider.dimensionId==0)
|
||||
GT_Pollution.onWorldTick((int) (aEvent.world.getTotalWorldTime() % 1200));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue