pollution effects for heavy metal and poison

This commit is contained in:
Bob 2023-06-24 17:54:46 +02:00
parent 00360a4586
commit 99cfce0e5d
8 changed files with 141 additions and 63 deletions

View File

@ -38,9 +38,14 @@
* The page and notebook items have been replaced with more dynamic book items that get their data from NBT
* C4 can now be made by irradiating PVC
* Play stupid games, win stupid prizes
* Gas grenades now use the new gas system which should be a lot more pleasant to look at and less heavy on the TPS
* Leaded fuels now release heavy metal into the air, heavy metal can cause lead poisoning
* Lower heavy metal concentrations can also cause heavy metal poisoning when breaking blocks
* Gas artillery shell now create heavy metal and poisonous pollution
## Fixed
* Fixed potential crash or logspam regarding the pollution handler
* Fixed missiles leaving behind a 3x3 grid of loaded chunks after being destroyed
* Fixed coal ore yielding coal in the crucible instead of making carbon
* Fixed a potential issue where BuildCraft generators can't supply the RF to HE converter
* Fixed a potential issue where BuildCraft generators can't supply the RF to HE converter
* Fixed combustion engine sound sometimes continue playing even when turned off

View File

@ -5,7 +5,9 @@ import net.minecraft.world.World;
import java.util.Random;
import com.hbm.entity.effect.EntityMist;
import com.hbm.explosion.ExplosionChaos;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.items.ModItems;
import com.hbm.items.weapon.ItemGrenade;
@ -30,21 +32,12 @@ public class EntityGrenadeGas extends EntityGrenadeBouncyBase {
if (!this.worldObj.isRemote) {
this.setDead();
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 0.0F, true);
// ExplosionChaos.poison(this.worldObj, (int)this.posX,
// (int)this.posY, (int)this.posZ, 5);
// for(int i = 0; 0 < 15; i++) {
/*
* ExplosionLarge.spawnParticlesRadial(worldObj, posX, posY, posZ,
* 50); ExplosionLarge.spawnParticlesRadial(worldObj, posX, posY,
* posZ, 50); ExplosionLarge.spawnParticlesRadial(worldObj, posX,
* posY, posZ, 50); ExplosionLarge.spawnParticlesRadial(worldObj,
* posX, posY, posZ, 50);
*/
ExplosionChaos.spawnChlorine(worldObj, posX, posY, posZ, 50, 1.25, 0);
// }
EntityMist mist = new EntityMist(worldObj);
mist.setType(Fluids.CHLORINE);
mist.setPosition(posX, posY - 5, posZ);
mist.setArea(15, 10);
worldObj.spawnEntityInWorld(mist);
}
}

View File

@ -12,6 +12,8 @@ import com.hbm.extprop.HbmLivingProps;
import com.hbm.extprop.HbmPlayerProps;
import com.hbm.extprop.HbmLivingProps.ContaminationEffect;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.interfaces.IArmorModDash;
import com.hbm.items.armor.ArmorFSB;
@ -19,6 +21,7 @@ import com.hbm.lib.ModDamageSource;
import com.hbm.main.MainRegistry;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.potion.HbmPotion;
import com.hbm.packet.ExtPropPacket;
import com.hbm.saveddata.AuxSavedData;
import com.hbm.util.ArmorRegistry;
@ -48,42 +51,40 @@ import net.minecraft.world.World;
public class EntityEffectHandler {
public static void onUpdate(EntityLivingBase entity) {
if(entity.ticksExisted % 20 == 0) {
HbmLivingProps.setRadBuf(entity, HbmLivingProps.getRadEnv(entity));
HbmLivingProps.setRadEnv(entity, 0);
}
if(entity instanceof EntityPlayerMP) {
HbmLivingProps props = HbmLivingProps.getData(entity);
HbmPlayerProps pprps = HbmPlayerProps.getData((EntityPlayerMP) entity);
NBTTagCompound data = new NBTTagCompound();
if(pprps.shield < pprps.maxShield && entity.ticksExisted > pprps.lastDamage + 60) {
int tsd = entity.ticksExisted - (pprps.lastDamage + 60);
pprps.shield += Math.min(pprps.maxShield - pprps.shield, 0.005F * tsd);
}
if(pprps.shield > pprps.maxShield)
pprps.shield = pprps.maxShield;
props.saveNBTData(data);
pprps.saveNBTData(data);
PacketDispatcher.wrapper.sendTo(new ExtPropPacket(data), (EntityPlayerMP) entity);
}
if(!entity.worldObj.isRemote) {
if(entity.ticksExisted % 20 == 0) {
HbmLivingProps.setRadBuf(entity, HbmLivingProps.getRadEnv(entity));
HbmLivingProps.setRadEnv(entity, 0);
}
if(entity instanceof EntityPlayerMP) {
HbmLivingProps props = HbmLivingProps.getData(entity);
HbmPlayerProps pprps = HbmPlayerProps.getData((EntityPlayerMP) entity);
NBTTagCompound data = new NBTTagCompound();
if(pprps.shield < pprps.maxShield && entity.ticksExisted > pprps.lastDamage + 60) {
int tsd = entity.ticksExisted - (pprps.lastDamage + 60);
pprps.shield += Math.min(pprps.maxShield - pprps.shield, 0.005F * tsd);
}
if(pprps.shield > pprps.maxShield)
pprps.shield = pprps.maxShield;
props.saveNBTData(data);
pprps.saveNBTData(data);
PacketDispatcher.wrapper.sendTo(new ExtPropPacket(data), (EntityPlayerMP) entity);
}
int timer = HbmLivingProps.getTimer(entity);
if(timer > 0) {
HbmLivingProps.setTimer(entity, timer - 1);
if(timer == 1) {
ExplosionNukeSmall.explode(entity.worldObj, entity.posX, entity.posY, entity.posZ, ExplosionNukeSmall.PARAMS_MEDIUM);
}
}
if(GeneralConfig.enable528 && entity instanceof EntityLivingBase && !entity.isImmuneToFire() && entity.worldObj.provider.isHellWorld) {
entity.setFire(5);
}
@ -95,6 +96,7 @@ public class EntityEffectHandler {
handleDigamma(entity);
handleLungDisease(entity);
handleOil(entity);
handlePollution(entity);
handleDashing(entity);
handlePlinking(entity);
@ -365,8 +367,11 @@ public class EntityEffectHandler {
double blacklung = Math.min(HbmLivingProps.getBlackLung(entity), HbmLivingProps.maxBlacklung);
double asbestos = Math.min(HbmLivingProps.getAsbestos(entity), HbmLivingProps.maxAsbestos);
double soot = PollutionHandler.getPollution(entity.worldObj, (int) Math.floor(entity.posX), (int) Math.floor(entity.posY + entity.getEyeHeight()), (int) Math.floor(entity.posZ), PollutionType.SOOT);
boolean coughs = blacklung / HbmLivingProps.maxBlacklung > 0.25D || asbestos / HbmLivingProps.maxAsbestos > 0.25D;
if(ArmorRegistry.hasProtection(entity, 3, HazardClass.PARTICLE_COARSE)) soot = 0;
boolean coughs = blacklung / HbmLivingProps.maxBlacklung > 0.25D || asbestos / HbmLivingProps.maxAsbestos > 0.25D || soot > 30;
if(!coughs)
return;
@ -377,11 +382,10 @@ public class EntityEffectHandler {
double blacklungDelta = 1D - (blacklung / (double)HbmLivingProps.maxBlacklung);
double asbestosDelta = 1D - (asbestos / (double)HbmLivingProps.maxAsbestos);
double sootDelta = 1D - Math.min(soot / 100, 1D);
double total = 1 - (blacklungDelta * asbestosDelta);
int freq = Math.max((int) (1000 - 950 * total), 20);
World world = entity.worldObj;
if(total > 0.75D) {
@ -392,6 +396,9 @@ public class EntityEffectHandler {
entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 100, 0));
}
total = 1 - (blacklungDelta * asbestosDelta * sootDelta);
int freq = Math.max((int) (1000 - 950 * total), 20);
if(world.getTotalWorldTime() % freq == entity.getEntityId() % freq) {
world.playSoundEffect(entity.posX, entity.posY, entity.posZ, "hbm:player.cough", 1.0F, 1.0F);
@ -442,6 +449,41 @@ public class EntityEffectHandler {
}
}
private static void handlePollution(EntityLivingBase entity) {
if(!ArmorRegistry.hasProtection(entity, 3, HazardClass.GAS_CORROSIVE) && entity.ticksExisted % 60 == 0) {
float poison = PollutionHandler.getPollution(entity.worldObj, (int) Math.floor(entity.posX), (int) Math.floor(entity.posY + entity.getEyeHeight()), (int) Math.floor(entity.posZ), PollutionType.POISON);
if(poison > 10) {
if(poison < 25) {
entity.addPotionEffect(new PotionEffect(Potion.poison.id, 100, 0));
} else if(poison < 50) {
entity.addPotionEffect(new PotionEffect(Potion.poison.id, 100, 2));
} else {
entity.addPotionEffect(new PotionEffect(Potion.wither.id, 100, 2));
}
}
}
if(!ArmorRegistry.hasProtection(entity, 3, HazardClass.PARTICLE_FINE) && entity.ticksExisted % 60 == 0) {
float poison = PollutionHandler.getPollution(entity.worldObj, (int) Math.floor(entity.posX), (int) Math.floor(entity.posY + entity.getEyeHeight()), (int) Math.floor(entity.posZ), PollutionType.HEAVYMETAL);
if(poison > 25) {
if(poison < 50) {
entity.addPotionEffect(new PotionEffect(HbmPotion.lead.id, 100, 0));
} else if(poison < 75) {
entity.addPotionEffect(new PotionEffect(HbmPotion.lead.id, 100, 2));
} else {
entity.addPotionEffect(new PotionEffect(HbmPotion.lead.id, 100, 2));
}
}
}
}
private static void handleDashing(Entity entity) {
//AAAAAAAAAAAAAAAAAAAAEEEEEEEEEEEEEEEEEEEE

View File

@ -169,6 +169,7 @@ public class PollutionHandler {
float[] pollutionForNeightbors = new float[PollutionType.values().length];
int S = PollutionType.SOOT.ordinal();
int H = PollutionType.HEAVYMETAL.ordinal();
int P = PollutionType.POISON.ordinal();
/* CALCULATION */
if(data.pollution[S] > 15) {
@ -178,7 +179,14 @@ public class PollutionHandler {
data.pollution[S] *= 0.99F;
}
data.pollution[H] *= 0.999F;
data.pollution[H] *= 0.9995F;
if(data.pollution[P] > 10) {
pollutionForNeightbors[P] = data.pollution[P] * 0.025F;
data.pollution[P] *= 0.9F;
} else {
data.pollution[P] *= 0.995F;
}
/* SPREADING */
//apply new data to self

View File

@ -36,7 +36,7 @@ public class GUICompressor extends GuiInfoContainer {
compressor.tanks[1].renderTankInfo(this, mouseX, mouseY, guiLeft + 107, guiTop + 18, 16, 52);
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 52, compressor.power, compressor.maxPower);
for(int j = 0; j < 5; j++) drawCustomInfoStat(mouseX, mouseY, guiLeft + 43 + j * 11, guiTop + 48, 8, 14, mouseX, mouseY, j + " PU -> " + (j + 1) + " PU");
for(int j = 0; j < 5; j++) drawCustomInfoStat(mouseX, mouseY, guiLeft + 43 + j * 11, guiTop + 46, 8, 14, mouseX, mouseY, j + " PU -> " + (j + 1) + " PU");
}
@Override

View File

@ -19,6 +19,8 @@ import com.hbm.explosion.vanillant.standard.BlockProcessorStandard;
import com.hbm.explosion.vanillant.standard.EntityProcessorCross;
import com.hbm.explosion.vanillant.standard.ExplosionEffectStandard;
import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
@ -318,6 +320,7 @@ public class ItemAmmoArty extends Item {
mist.setPosition(mop.hitVec.xCoord - vec.xCoord, mop.hitVec.yCoord - vec.yCoord - 3, mop.hitVec.zCoord - vec.zCoord);
mist.setArea(15, 7.5F);
shell.worldObj.spawnEntityInWorld(mist);
PollutionHandler.incrementPollution(shell.worldObj, mop.blockX, mop.blockY, mop.blockZ, PollutionType.HEAVYMETAL, 5F);
}
};
this.itemTypes[PHOSGENE] = new ArtilleryShell("ammo_arty_phosgene", SpentCasing.COLOR_CASE_16INCH_NUKE) {
@ -326,18 +329,20 @@ public class ItemAmmoArty extends Item {
Vec3 vec = Vec3.createVectorHelper(shell.motionX, shell.motionY, shell.motionZ).normalize();
shell.worldObj.createExplosion(shell, mop.hitVec.xCoord - vec.xCoord, mop.hitVec.yCoord - vec.yCoord, mop.hitVec.zCoord - vec.zCoord, 5F, false);
for(int i = 0; i < 3; i++) {
EntityMist mist = new EntityMist(shell.worldObj);
mist.setType(Fluids.PHOSGENE);
double x = mop.hitVec.xCoord - vec.xCoord;
double z = mop.hitVec.zCoord - vec.zCoord;
if(i > 0) {
x += rand.nextGaussian() * 15;
z += rand.nextGaussian() * 15;
EntityMist mist = new EntityMist(shell.worldObj);
mist.setType(Fluids.PHOSGENE);
double x = mop.hitVec.xCoord - vec.xCoord;
double z = mop.hitVec.zCoord - vec.zCoord;
if(i > 0) {
x += rand.nextGaussian() * 15;
z += rand.nextGaussian() * 15;
}
mist.setPosition(x, mop.hitVec.yCoord - vec.yCoord - 5, z);
mist.setArea(15, 10);
shell.worldObj.spawnEntityInWorld(mist);
}
mist.setPosition(x, mop.hitVec.yCoord - vec.yCoord - 5, z);
mist.setArea(15, 10);
shell.worldObj.spawnEntityInWorld(mist);
}
PollutionHandler.incrementPollution(shell.worldObj, mop.blockX, mop.blockY, mop.blockZ, PollutionType.HEAVYMETAL, 10F);
PollutionHandler.incrementPollution(shell.worldObj, mop.blockX, mop.blockY, mop.blockZ, PollutionType.POISON, 15F);
}
};
this.itemTypes[MUSTARD] = new ArtilleryShell("ammo_arty_mustard_gas", SpentCasing.COLOR_CASE_16INCH_NUKE) {
@ -358,6 +363,8 @@ public class ItemAmmoArty extends Item {
mist.setArea(20, 10);
shell.worldObj.spawnEntityInWorld(mist);
}
PollutionHandler.incrementPollution(shell.worldObj, mop.blockX, mop.blockY, mop.blockZ, PollutionType.HEAVYMETAL, 15F);
PollutionHandler.incrementPollution(shell.worldObj, mop.blockX, mop.blockY, mop.blockZ, PollutionType.POISON, 30F);
}
};

View File

@ -41,6 +41,8 @@ import com.hbm.hazard.HazardSystem;
import com.hbm.interfaces.IBomb;
import com.hbm.handler.HTTPHandler;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.handler.SiegeOrchestrator;
import com.hbm.items.IEquipReceiver;
import com.hbm.items.ModItems;
@ -65,12 +67,14 @@ import com.hbm.potion.HbmPotion;
import com.hbm.saveddata.AuxSavedData;
import com.hbm.tileentity.network.RTTYSystem;
import com.hbm.util.AchievementHandler;
import com.hbm.util.ArmorRegistry;
import com.hbm.util.ArmorUtil;
import com.hbm.util.ContaminationUtil;
import com.hbm.util.EnchantmentUtil;
import com.hbm.util.EntityDamageUtil;
import com.hbm.util.EnumUtil;
import com.hbm.util.InventoryUtil;
import com.hbm.util.ArmorRegistry.HazardClass;
import com.hbm.world.generator.TimedGenerator;
import cpw.mods.fml.common.eventhandler.EventPriority;
@ -1149,10 +1153,12 @@ public class ModEventHandler {
@SubscribeEvent
public void onBlockBreak(BreakEvent event) {
if(!(event.getPlayer() instanceof EntityPlayerMP))
EntityPlayer player = event.getPlayer();
if(!(player instanceof EntityPlayerMP))
return;
if(event.block == ModBlocks.stone_gneiss && !((EntityPlayerMP) event.getPlayer()).func_147099_x().hasAchievementUnlocked(MainRegistry.achStratum)) {
if(event.block == ModBlocks.stone_gneiss && !((EntityPlayerMP) player).func_147099_x().hasAchievementUnlocked(MainRegistry.achStratum)) {
event.getPlayer().triggerAchievement(MainRegistry.achStratum);
event.setExpToDrop(500);
}
@ -1169,6 +1175,21 @@ public class ModEventHandler {
event.world.setBlock(x, y, z, ModBlocks.gas_coal);
}
}
if(!ArmorRegistry.hasProtection(player, 3, HazardClass.PARTICLE_FINE)) {
float metal = PollutionHandler.getPollution(player.worldObj, event.x, event.y, event.z, PollutionType.HEAVYMETAL);
if(metal < 5) return;
if(metal < 10) {
player.addPotionEffect(new PotionEffect(HbmPotion.lead.id, 100, 0));
} else if(metal < 25) {
player.addPotionEffect(new PotionEffect(HbmPotion.lead.id, 100, 1));
} else {
player.addPotionEffect(new PotionEffect(HbmPotion.lead.id, 100, 2));
}
}
}
private static final String hash = "41eb77f138ce350932e33b6b26b233df9aad0c0c80c6a49cb9a54ddd8fae3f83";

View File

@ -142,6 +142,8 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachineBase imp
audio = rebootAudio(audio);
}
audio.keepAlive();
} else {
if(audio != null) {
@ -165,7 +167,7 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachineBase imp
}
public AudioWrapper createAudioLoop() {
return MainRegistry.proxy.getLoopedSound("hbm:block.igeneratorOperate", xCoord, yCoord, zCoord, 1.0F, 10F, 1.0F);
return MainRegistry.proxy.getLoopedSound("hbm:block.igeneratorOperate", xCoord, yCoord, zCoord, 1.0F, 10F, 1.0F, 20);
}
@Override