public class Haemorrhage extends MobEffect { public int passiveDMGdelay = 50; public static DamageSource BLEEDING = new DamageSource("bleeding"); public Haemorrhage(MobEffectCategory pCategory, int pColor) { super(pCategory, pColor); } @Override public boolean isDurationEffectTick(int pDuration, int pAmplifier) { passiveDMGdelay = Math.max(0, passiveDMGdelay - 1); return true; } @Override public void applyEffectTick(LivingEntity pLivingEntity, int pAmplifier) { float damage; // calculates player's horizontal movement speed double dx = pLivingEntity.getDeltaMovement().x(); double dz = pLivingEntity.getDeltaMovement().z(); double velocity = Math.sqrt(dx * dx + dz * dz); if (velocity == 0 || pLivingEntity.isCrouching()) { if (passiveDMGdelay == 0) { damage = 1F; pLivingEntity.hurt(BLEEDING, damage); passiveDMGdelay = Math.max(40, 80 - pAmplifier * 5); } } else if (velocity > 0) { damage = (float) ((pAmplifier * 0.25F + 1) * (pLivingEntity.isSprinting() && pLivingEntity.isOnGround() ? velocity * 50 : velocity * 20)); pLivingEntity.hurt(BLEEDING, 2F); passiveDMGdelay = Math.max(25, 50 - pAmplifier * 5); } } }