Java Code Examples for net.minecraft.util.DamageSource#isUnblockable()

The following examples show how to use net.minecraft.util.DamageSource#isUnblockable() . 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: CraftDamageSource.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static DamageSource copyOf(final DamageSource original) {
    CraftDamageSource newSource = new CraftDamageSource(original.damageType);

    // Check ignoresArmor
    if (original.isUnblockable()) {
        newSource.setDamageBypassesArmor();
    }

    // Check magic
    if (original.isMagicDamage()) {
        newSource.setMagicDamage();
    }

    // Check fire
    if (original.isExplosion()) {
        newSource.setExplosion();
    }

    return newSource;
}
 
Example 2
Source File: ItemHeartUpgrade.java    From Cyberware with MIT License 5 votes vote down vote up
protected float applyArmorCalculations(EntityLivingBase e, DamageSource source, float damage)
{
    if (!source.isUnblockable())
    {
        damage = CombatRules.getDamageAfterAbsorb(damage, (float)e.getTotalArmorValue(), (float)e.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue());
    }

    return damage;
}
 
Example 3
Source File: ItemSpaceArmor.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public ArmorProperties getProperties(EntityLivingBase player,
		ItemStack armor, DamageSource source, double damage, int slot) {
	if(!source.isUnblockable())
		return new ArmorProperties(0, 5, 1);
	return new ArmorProperties(0, 0, 0);
}
 
Example 4
Source File: ItemPack.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    T pack = this.getPack(armor);
    if (pack != null && pack.isArmored && !source.isUnblockable()) {
        if (pack.isFluxBased && source.damageType.equals("flux")) {
            return new ArmorProperties(0, 0.5D, Integer.MAX_VALUE);
        }
        int energyPerDamage = this.getFuelPerDamage(armor, pack);
        int maxAbsorbed = energyPerDamage > 0 ? 25 * (this.getFuelStored(armor) / energyPerDamage) : 0;
        return new ArmorProperties(0, 0.85D * (pack.armorReduction / 20.0D), maxAbsorbed);
    }
    return new ArmorProperties(0, 1, 0);
}
 
Example 5
Source File: ItemElectricGoggles.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 0);
    } else {
        double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
        int energyPerDamage = getEnergyPerDamage();
        double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage;
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, absorptionRatio, (int) damageLimit);
    }
}
 
Example 6
Source File: ItemNanoWing.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3);
    } else {
        double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
        int energyPerDamage = getEnergyPerDamage();
        double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage;
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit);
    }
}
 
Example 7
Source File: ItemElectricBootsTraveller.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3);
    } else {
        double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
        int energyPerDamage = getEnergyPerDamage();
        double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage;
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit);
    }
}
 
Example 8
Source File: EntityDireSlime.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
protected float applyArmorCalculations(DamageSource p_70655_1_, float p_70655_2_) {
    if (!p_70655_1_.isUnblockable()) {
      return Math.min(Math.max(p_70655_2_ - 3 - this.getSlimeSize(), this.getSlimeSize()) / 2, p_70655_2_);
    }
    return p_70655_2_;
}