@SuppressWarnings("ConstantConditions") private void effect(EntityLivingBase e) { if (isFluid) e.getCapability(ArbitraryCaps.CAPABILITY_ARBITRARY_STATS, null) .addFluidDebuff(fluid, fluid.getViscosity() / 200); else { potion.getEffects().forEach(eff -> e.addPotionEffect(new PotionEffect(eff))); custom.forEach(eff -> e.addPotionEffect(new PotionEffect(eff))); } }
@Override protected void readEntityFromNBT(NBTTagCompound nbt) { if (nbt.hasKey("Fluid")) { fluid = FluidRegistry.getFluid(nbt.getString("Fluid")); dataManager.set(COLOR, fluid.getColor()); isFluid = true; } else if (nbt.hasKey("Potion")) { potion = PotionType.getPotionTypeForName(nbt.getString("Potion")); dataManager.set(COLOR, fluid.getColor()); isFluid = false; } else setDead(); dataManager.setDirty(COLOR); }
@Override protected void writeEntityToNBT(NBTTagCompound nbt) { if (isFluid) nbt.setString("Fluid", fluid.getName()); else nbt.setString("Potion", potion.getRegistryName().toString()); }