mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
more gas funnies
This commit is contained in:
parent
971ba04d24
commit
68d28a214e
@ -45,6 +45,11 @@ public class BlockStalagmite extends BlockEnumMulti {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getMetaFromResource(int meta) {
|
||||
return meta;
|
||||
|
||||
@ -1,14 +1,35 @@
|
||||
package com.hbm.entity.effect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.extprop.HbmLivingProps;
|
||||
import com.hbm.handler.radiation.ChunkRadiationManager;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.trait.FT_Corrosive;
|
||||
import com.hbm.inventory.fluid.trait.FT_Flammable;
|
||||
import com.hbm.inventory.fluid.trait.FT_Poison;
|
||||
import com.hbm.inventory.fluid.trait.FT_Toxin;
|
||||
import com.hbm.inventory.fluid.trait.FT_VentRadiation;
|
||||
import com.hbm.inventory.fluid.trait.FluidTraitSimple.FT_Gaseous;
|
||||
import com.hbm.inventory.fluid.trait.FluidTraitSimple.FT_Gaseous_ART;
|
||||
import com.hbm.inventory.fluid.trait.FluidTraitSimple.FT_Liquid;
|
||||
import com.hbm.inventory.fluid.trait.FluidTraitSimple.FT_Viscous;
|
||||
import com.hbm.lib.ModDamageSource;
|
||||
import com.hbm.util.ArmorUtil;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
import com.hbm.util.EntityDamageUtil;
|
||||
import com.hbm.util.ContaminationUtil.ContaminationType;
|
||||
import com.hbm.util.ContaminationUtil.HazardType;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityMist extends Entity {
|
||||
@ -16,6 +37,7 @@ public class EntityMist extends Entity {
|
||||
public EntityMist(World world) {
|
||||
super(world);
|
||||
this.noClip = true;
|
||||
this.setSize(10F, 3F);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,6 +58,113 @@ public class EntityMist extends Entity {
|
||||
@Override
|
||||
public void onEntityUpdate() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(this.ticksExisted > this.getMaxAge()) {
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
FluidType type = this.getType();
|
||||
|
||||
if(type.hasTrait(FT_VentRadiation.class)) {
|
||||
FT_VentRadiation trait = type.getTrait(FT_VentRadiation.class);
|
||||
ChunkRadiationManager.proxy.incrementRad(worldObj, (int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ), trait.getRadPerMB() * 2);
|
||||
}
|
||||
|
||||
double intensity = 1D - (double) this.ticksExisted / (double) this.getMaxAge();
|
||||
|
||||
if(type.hasTrait(FT_Flammable.class) && this.isBurning()) {
|
||||
worldObj.createExplosion(this, posX, posY + height / 2, posZ, (float) intensity * 15F, true);
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
List<Entity> affected = worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox);
|
||||
|
||||
for(Entity e : affected) {
|
||||
this.affect(e, intensity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* can't reuse EntityChemical here, while similar or identical in some places, the actual effects are often different */
|
||||
protected void affect(Entity e, double intensity) {
|
||||
|
||||
FluidType type = this.getType();
|
||||
EntityLivingBase living = e instanceof EntityLivingBase ? (EntityLivingBase) e : null;
|
||||
|
||||
if(type.temperature >= 100) {
|
||||
EntityDamageUtil.attackEntityFromIgnoreIFrame(e, new DamageSource(ModDamageSource.s_boil), 5F + (type.temperature - 100) * 0.02F);
|
||||
|
||||
if(type.temperature >= 500) {
|
||||
e.setFire(10); //afterburn for 10 seconds
|
||||
}
|
||||
}
|
||||
if(type.temperature < -20) {
|
||||
if(living != null) { //only living things are affected
|
||||
EntityDamageUtil.attackEntityFromIgnoreIFrame(e, new DamageSource(ModDamageSource.s_cryolator), 5F + (type.temperature + 20) * -0.05F); //5 damage at -20°C with one extra damage every -20°C
|
||||
living.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 2));
|
||||
living.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 100, 4));
|
||||
}
|
||||
}
|
||||
|
||||
if(type.hasTrait(Fluids.DELICIOUS.getClass())) {
|
||||
if(living != null && living.isEntityAlive()) {
|
||||
living.heal(2F * (float) intensity);
|
||||
}
|
||||
}
|
||||
|
||||
if(type.hasTrait(FT_Flammable.class)) {
|
||||
if(living != null) {
|
||||
HbmLivingProps.setOil(living, 200); //doused in oil for 10 seconds
|
||||
}
|
||||
}
|
||||
|
||||
if(this.isExtinguishing(type)) {
|
||||
e.extinguish();
|
||||
}
|
||||
|
||||
if(type.hasTrait(FT_Corrosive.class)) {
|
||||
FT_Corrosive trait = type.getTrait(FT_Corrosive.class);
|
||||
EntityDamageUtil.attackEntityFromIgnoreIFrame(e, new DamageSource(ModDamageSource.s_acid), trait.getRating() / 20F);
|
||||
|
||||
if(living != null) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
ArmorUtil.damageSuit(living, i, trait.getRating() / 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(type.hasTrait(FT_VentRadiation.class)) {
|
||||
FT_VentRadiation trait = type.getTrait(FT_VentRadiation.class);
|
||||
if(living != null) {
|
||||
ContaminationUtil.contaminate(living, HazardType.RADIATION, ContaminationType.CREATIVE, trait.getRadPerMB() * 5);
|
||||
}
|
||||
}
|
||||
|
||||
if(type.hasTrait(FT_Poison.class)) {
|
||||
FT_Poison trait = type.getTrait(FT_Poison.class);
|
||||
|
||||
if(living != null) {
|
||||
living.addPotionEffect(new PotionEffect(trait.isWithering() ? Potion.wither.id : Potion.poison.id, (int) (5 * 20 * intensity)));
|
||||
}
|
||||
}
|
||||
|
||||
if(type.hasTrait(FT_Toxin.class)) {
|
||||
FT_Toxin trait = type.getTrait(FT_Toxin.class);
|
||||
|
||||
if(living != null) {
|
||||
trait.affect(living, intensity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isExtinguishing(FluidType type) {
|
||||
return this.getStyleFromType(type) == SprayStyle.MIST && this.getType().temperature < 50 && !type.hasTrait(FT_Flammable.class);
|
||||
}
|
||||
|
||||
public int getMaxAge() {
|
||||
return getStyleFromType(this.getType()) == SprayStyle.GAS ? 600 : 150;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,6 +176,12 @@ public class EntityMist extends Entity {
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("type", this.getType().getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean canRenderOnFire() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static SprayStyle getStyleFromType(FluidType type) {
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import com.hbm.inventory.fluid.trait.FT_Combustible;
|
||||
import com.hbm.inventory.fluid.trait.FT_Corrosive;
|
||||
import com.hbm.inventory.fluid.trait.FT_Flammable;
|
||||
import com.hbm.inventory.fluid.trait.FT_Poison;
|
||||
import com.hbm.inventory.fluid.trait.FT_Toxin;
|
||||
import com.hbm.inventory.fluid.trait.FT_VentRadiation;
|
||||
import com.hbm.lib.ModDamageSource;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -253,6 +254,14 @@ public class EntityChemical extends EntityThrowableNT {
|
||||
}
|
||||
}
|
||||
|
||||
if(type.hasTrait(FT_Toxin.class)) {
|
||||
FT_Toxin trait = type.getTrait(FT_Toxin.class);
|
||||
|
||||
if(living != null) {
|
||||
trait.affect(living, intensity);
|
||||
}
|
||||
}
|
||||
|
||||
if(type == Fluids.XPJUICE) {
|
||||
|
||||
if(e instanceof EntityPlayer) {
|
||||
|
||||
@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
@Deprecated //use FT_Toxin instead
|
||||
public class FT_Poison extends FluidTrait {
|
||||
|
||||
protected boolean withering = false;
|
||||
|
||||
@ -32,6 +32,10 @@ public class FT_Toxin extends FluidTrait {
|
||||
entry.addInfo(info);
|
||||
}
|
||||
}
|
||||
|
||||
public void affect(EntityLivingBase entity, double intensity) {
|
||||
|
||||
}
|
||||
|
||||
public static abstract class ToxinEntry {
|
||||
|
||||
@ -60,7 +64,7 @@ public class FT_Toxin extends FluidTrait {
|
||||
return hasMask && hasSuit;
|
||||
}
|
||||
|
||||
public abstract void poison(EntityLivingBase entity);
|
||||
public abstract void poison(EntityLivingBase entity, double intensity);
|
||||
public abstract void addInfo(List<String> info);
|
||||
}
|
||||
|
||||
@ -78,12 +82,12 @@ public class FT_Toxin extends FluidTrait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void poison(EntityLivingBase entity) {
|
||||
public void poison(EntityLivingBase entity, double intensity) {
|
||||
|
||||
if(isProtected(entity)) return;
|
||||
|
||||
if(delay == 0 || entity.worldObj.getTotalWorldTime() % delay == 0) {
|
||||
entity.attackEntityFrom(damage, amount);
|
||||
entity.attackEntityFrom(damage, (float) (amount * intensity));
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,15 +106,15 @@ public class FT_Toxin extends FluidTrait {
|
||||
}
|
||||
|
||||
public ToxinEffects add(PotionEffect... effs) {
|
||||
for(PotionEffect eff : effs)this.effects.add(eff);
|
||||
for(PotionEffect eff : effs) this.effects.add(eff);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void poison(EntityLivingBase entity) {
|
||||
public void poison(EntityLivingBase entity, double intensity) {
|
||||
|
||||
for(PotionEffect eff : effects) {
|
||||
entity.addPotionEffect(new PotionEffect(eff));
|
||||
entity.addPotionEffect(new PotionEffect(eff.getPotionID(), (int) (eff.getDuration() * intensity), eff.getAmplifier()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user