Search in sources :

Example 1 with ParticleTextPopOff

use of org.blockartistry.DynSurround.client.fx.particle.ParticleTextPopOff in project DynamicSurroundings by OreCruncher.

the class EntityHealthPopoffEffect method update.

@Override
public void update(@Nonnull final Entity subject) {
    if (!ModOptions.player.enableDamagePopoffs)
        return;
    final EntityLivingBase entity = (EntityLivingBase) subject;
    if (this.lastHealth != entity.getHealth()) {
        final World world = EnvironState.getWorld();
        final int adjustment = MathHelper.ceil(entity.getHealth() - this.lastHealth);
        this.lastHealth = entity.getHealth();
        // Don't display if it is the current player in first person view
        if (!EnvironState.isPlayer(subject) || !isFirstPersonView()) {
            final int delta = Math.max(1, MathStuff.abs(adjustment));
            final int criticalAmount = (int) (entity.getMaxHealth() / 2.5F);
            final AxisAlignedBB bb = entity.getEntityBoundingBox();
            final double posX = entity.posX;
            final double posY = bb.maxY + 0.5D;
            final double posZ = entity.posZ;
            final String text = String.valueOf(delta);
            final Color color = adjustment > 0 ? HEAL_TEXT_COLOR : DAMAGE_TEXT_COLOR;
            ParticleTextPopOff particle = null;
            if (ModOptions.player.showCritWords && adjustment < 0 && delta >= criticalAmount) {
                particle = new ParticleTextPopOff(world, getPowerWord(), CRITICAL_TEXT_COLOR, posX, posY + 0.5D, posZ);
                getState().addParticle(particle);
            }
            particle = new ParticleTextPopOff(world, text, color, posX, posY, posZ);
            getState().addParticle(particle);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ParticleTextPopOff(org.blockartistry.DynSurround.client.fx.particle.ParticleTextPopOff) Color(org.blockartistry.lib.Color) EntityLivingBase(net.minecraft.entity.EntityLivingBase) World(net.minecraft.world.World)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 World (net.minecraft.world.World)1 ParticleTextPopOff (org.blockartistry.DynSurround.client.fx.particle.ParticleTextPopOff)1 Color (org.blockartistry.lib.Color)1