Java Code Examples for net.minecraft.entity.player.EntityPlayer#getRidingEntity()

The following examples show how to use net.minecraft.entity.player.EntityPlayer#getRidingEntity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataHelper.java    From GokiStats with MIT License 6 votes vote down vote up
public static float getDamageDealt(EntityPlayer player, Entity target, DamageSource source) {
    float damage = (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    float bonusDamage = 0.0F;
    boolean targetIsLiving = target instanceof EntityLivingBase;
    boolean critical;
    ItemStack stack = player.getHeldItemMainhand();
    if (targetIsLiving) {
        bonusDamage = EnchantmentHelper.getModifierForCreature(stack, ((EntityLivingBase) target).getCreatureAttribute());
    }
    if ((damage > 0.0F) || (bonusDamage > 0.0F)) {
        critical = (player.fallDistance > 0.0F) && (!player.onGround) && (!player.isOnLadder()) && (!player.isInWater()) && (!player.isPotionActive(Potion.getPotionFromResourceLocation("blindness"))) && (player.getRidingEntity() == null) && (targetIsLiving);
        if ((critical) && (damage > 0.0F)) {
            damage *= 1.5F;
        }
        damage += bonusDamage;
    }
    return damage;
}