Search in sources :

Example 1 with BuffEffectSlowfall

use of am2.buffs.BuffEffectSlowfall in project ArsMagica2 by Mithion.

the class FallProtection method applyEffect.

@Override
public boolean applyEffect(EntityPlayer player, World world, ItemStack stack, ImbuementApplicationTypes matchedType, Object... params) {
    if (world.isRemote)
        return false;
    int distanceToGround = MathUtilities.getDistanceToGround(player, world);
    ExtendedProperties extendedProperties = ExtendedProperties.For(player);
    if (player.fallDistance >= extendedProperties.getFallProtection() + 4f && distanceToGround < -8 * player.motionY) {
        if (!player.isPotionActive(BuffList.slowfall.id) && !player.capabilities.isFlying) {
            BuffEffectSlowfall sf = new BuffEffectSlowfall(distanceToGround * 3, 1);
            player.addPotionEffect(sf);
            stack.damageItem((int) (player.fallDistance * 6), player);
            player.fallDistance = 0;
            return true;
        }
    }
    return false;
}
Also used : BuffEffectSlowfall(am2.buffs.BuffEffectSlowfall) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Aggregations

BuffEffectSlowfall (am2.buffs.BuffEffectSlowfall)1 ExtendedProperties (am2.playerextensions.ExtendedProperties)1