funny toxic fluids

This commit is contained in:
Boblet 2023-04-17 14:45:54 +02:00
parent 8574e86fdc
commit 971ba04d24
4 changed files with 146 additions and 12 deletions

View File

@ -15,6 +15,7 @@ public class EntityMist extends Entity {
public EntityMist(World world) {
super(world);
this.noClip = true;
}
@Override
@ -30,15 +31,21 @@ public class EntityMist extends Entity {
public FluidType getType() {
return Fluids.fromID(this.dataWatcher.getWatchableObjectInt(10));
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbt) {
public void onEntityUpdate() {
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbt) {
this.setFluid(Fluids.fromID(nbt.getInteger("type")));
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
nbt.setInteger("type", this.getType().getID());
}
public static SprayStyle getStyleFromType(FluidType type) {

View File

@ -6,10 +6,16 @@ import java.util.List;
import com.hbm.inventory.fluid.trait.*;
import com.hbm.inventory.fluid.trait.FluidTraitSimple.*;
import com.hbm.lib.ModDamageSource;
import com.hbm.inventory.fluid.trait.FT_Combustible.FuelGrade;
import com.hbm.inventory.fluid.trait.FT_Coolable.CoolingType;
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingType;
import com.hbm.inventory.fluid.trait.FT_Toxin.*;
import com.hbm.render.util.EnumSymbol;
import com.hbm.util.ArmorRegistry.HazardClass;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
public class Fluids {
@ -253,7 +259,6 @@ public class Fluids {
MUSTARDGAS = new FluidType("MUSTARDGAS", 0xBAB572, 4, 1, 1, EnumSymbol.NONE).addContainers(new CD_Gastank(0xBAB572, 0x361414)).addTraits(GASEOUS);
IONGEL = new FluidType(103, "IONGEL", 0xB8FFFF, 1, 0, 4, EnumSymbol.NONE).addTraits(LIQUID, VISCOUS);
// ^ ^ ^ ^ ^ ^ ^ ^
//ADD NEW FLUIDS HERE
//AND DON'T FORGET THE META DOWN HERE
@ -377,6 +382,11 @@ public class Fluids {
metaOrder.add(PLASMA_XM);
metaOrder.add(PLASMA_BF);
CHLORINE.addTraits(new FT_Toxin().addEntry(new ToxinDirectDamage(ModDamageSource.cloud, 2F, 20, HazardClass.GAS_CHLORINE, false)));
PHOSGENE.addTraits(new FT_Toxin().addEntry(new ToxinDirectDamage(ModDamageSource.cloud, 4F, 20, HazardClass.GAS_CHLORINE, false)));
MUSTARDGAS.addTraits(new FT_Toxin().addEntry(new ToxinDirectDamage(ModDamageSource.cloud, 4F, 10, HazardClass.GAS_CORROSIVE, false))
.addEntry(new ToxinEffects(HazardClass.GAS_CORROSIVE, true).add(new PotionEffect(Potion.wither.id, 100, 1), new PotionEffect(Potion.confusion.id, 100, 0))));
double eff_steam_boil = 1.0D;
double eff_steam_heatex = 0.25D;

View File

@ -0,0 +1,126 @@
package com.hbm.inventory.fluid.trait;
import java.util.ArrayList;
import java.util.List;
import com.hbm.util.ArmorRegistry;
import com.hbm.util.ArmorUtil;
import com.hbm.util.I18nUtil;
import com.hbm.util.ArmorRegistry.HazardClass;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.util.StringUtils;
public class FT_Toxin extends FluidTrait {
public List<ToxinEntry> entries = new ArrayList();
public FT_Toxin addEntry(ToxinEntry entry) {
entries.add(entry);
return this;
}
@Override
public void addInfoHidden(List<String> info) {
info.add(EnumChatFormatting.LIGHT_PURPLE + "[Toxin]");
for(ToxinEntry entry : entries) {
entry.addInfo(info);
}
}
public static abstract class ToxinEntry {
public HazardClass clazz;
public boolean fullBody = false;
public ToxinEntry(HazardClass clazz, boolean fullBody) {
this.clazz = clazz;
this.fullBody = fullBody;
}
public boolean isProtected(EntityLivingBase entity) {
boolean hasMask = clazz == null;
boolean hasSuit = !fullBody;
if(clazz != null && ArmorRegistry.hasAllProtection(entity, 3, clazz)) {
ArmorUtil.damageGasMaskFilter(entity, 1);
hasMask = true;
}
if(fullBody && ArmorUtil.checkForHazmat(entity)) {
hasSuit = true;
}
return hasMask && hasSuit;
}
public abstract void poison(EntityLivingBase entity);
public abstract void addInfo(List<String> info);
}
public static class ToxinDirectDamage extends ToxinEntry {
public DamageSource damage;
public float amount;
public int delay;
public ToxinDirectDamage(DamageSource damage, float amount, int delay, HazardClass clazz, boolean fullBody) {
super(clazz, fullBody);
this.damage = damage;
this.amount = amount;
this.delay = delay;
}
@Override
public void poison(EntityLivingBase entity) {
if(isProtected(entity)) return;
if(delay == 0 || entity.worldObj.getTotalWorldTime() % delay == 0) {
entity.attackEntityFrom(damage, amount);
}
}
@Override
public void addInfo(List<String> info) {
info.add(EnumChatFormatting.YELLOW + "- " + I18nUtil.resolveKey(clazz.lang) + (fullBody ? EnumChatFormatting.RED + " (requires hazmat suit)" : "") + ": " + EnumChatFormatting.YELLOW + String.format("%,.1f", amount * 20 / delay) + " DPS");
}
}
public static class ToxinEffects extends ToxinEntry {
public List<PotionEffect> effects = new ArrayList();
public ToxinEffects(HazardClass clazz, boolean fullBody) {
super(clazz, fullBody);
}
public ToxinEffects add(PotionEffect... effs) {
for(PotionEffect eff : effs)this.effects.add(eff);
return this;
}
@Override
public void poison(EntityLivingBase entity) {
for(PotionEffect eff : effects) {
entity.addPotionEffect(new PotionEffect(eff));
}
}
@Override
public void addInfo(List<String> info) {
info.add(EnumChatFormatting.YELLOW + "- " + I18nUtil.resolveKey(clazz.lang) + (fullBody ? EnumChatFormatting.RED + " (requires hazmat suit)" + EnumChatFormatting.YELLOW : "") + ":");
for(PotionEffect eff : effects) {
info.add(EnumChatFormatting.YELLOW + " - " + I18nUtil.resolveKey(eff.getEffectName()) + (eff.getAmplifier() > 0 ? " " + StatCollector.translateToLocal("potion.potency." + eff.getAmplifier()).trim() : "") + " " + StringUtils.ticksToElapsedTime(eff.getDuration()));
}
}
}
}

View File

@ -117,13 +117,4 @@ public class ArmorRegistry {
this.lang = lang;
}
}
/*public static enum ArmorClass {
MASK_FILTERED,
MASK_OXY,
GOGGLES,
HAZMAT_HEAT,
HAZMAT_RADIATION,
HAZMAT_BIO;
}*/
}