protected boolean damageEntity_CB(DamageSource p_70665_1_, float p_70665_2_) // void -> boolean { if (true) { return super.damageEntity_CB(p_70665_1_, p_70665_2_); } // CraftBukkit end if (!this.isEntityInvulnerable()) { p_70665_2_ = ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_); if (p_70665_2_ <= 0) return false; if (!p_70665_1_.isUnblockable() && this.isBlocking() && p_70665_2_ > 0.0F) { p_70665_2_ = (1.0F + p_70665_2_) * 0.5F; } p_70665_2_ = ArmorProperties.ApplyArmor(this, inventory.armorInventory, p_70665_1_, p_70665_2_); if (p_70665_2_ <= 0) return false; p_70665_2_ = this.applyPotionDamageCalculations(p_70665_1_, p_70665_2_); float f1 = p_70665_2_; p_70665_2_ = Math.max(p_70665_2_ - this.getAbsorptionAmount(), 0.0F); this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - p_70665_2_)); if (p_70665_2_ != 0.0F) { this.addExhaustion(p_70665_1_.getHungerDamage()); float f2 = this.getHealth(); this.setHealth(this.getHealth() - p_70665_2_); this.func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_); } } return false; }
protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_) { if (!this.isEntityInvulnerable()) { p_70665_2_ = ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_); if (p_70665_2_ <= 0) return; if (!p_70665_1_.isUnblockable() && this.isBlocking() && p_70665_2_ > 0.0F) { p_70665_2_ = (1.0F + p_70665_2_) * 0.5F; } p_70665_2_ = ArmorProperties.ApplyArmor(this, inventory.armorInventory, p_70665_1_, p_70665_2_); if (p_70665_2_ <= 0) return; p_70665_2_ = this.applyPotionDamageCalculations(p_70665_1_, p_70665_2_); float f1 = p_70665_2_; p_70665_2_ = Math.max(p_70665_2_ - this.getAbsorptionAmount(), 0.0F); this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - p_70665_2_)); if (p_70665_2_ != 0.0F) { this.addExhaustion(p_70665_1_.getHungerDamage()); float f2 = this.getHealth(); this.setHealth(this.getHealth() - p_70665_2_); this.func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_); } } }
/** * Deals damage to the entity. If its a EntityPlayer then will take damage from the armor first and then health * second with the reduced value. Args: damageAmount */ protected void damageEntity(DamageSource par1DamageSource, float par2) { if (!this.isEntityInvulnerable()) { par2 = ForgeHooks.onLivingHurt(this, par1DamageSource, par2); if (par2 <= 0) return; if (!par1DamageSource.isUnblockable() && this.isBlocking() && par2 > 0.0F) { par2 = (1.0F + par2) * 0.5F; } par2 = ArmorProperties.ApplyArmor(this, inventory.armorInventory, par1DamageSource, par2); if (par2 <= 0) return; par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); float f1 = par2; par2 = Math.max(par2 - this.getAbsorptionAmount(), 0.0F); this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - par2)); if (par2 != 0.0F) { this.addExhaustion(par1DamageSource.getHungerDamage()); float f2 = this.getHealth(); this.setHealth(this.getHealth() - par2); this.func_110142_aN().func_94547_a(par1DamageSource, f2, par2); } } }
/** * Get the properties for the armour. * * @param player * @param stack * @param source * @param damage * @param slot * @return The properties detailing the reaction on hit. */ @Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) { ArmorProperties output = new ArmorProperties(0, 0, 0); for (IUpgrade upgrade : NBTHelper.getNBTUpgradeList(stack.stackTagCompound)) { ArmorProperties prop = null; if (upgrade instanceof IArmourUpgrade) { prop = ((IArmourUpgrade) upgrade).getProperties(player, stack, source, damage, ArmourSlot.getArmourSlot(slot)); } if (prop == null) { continue; } if (prop.Priority > output.Priority) { output = prop; } else if (prop.Priority == output.Priority && prop.AbsorbRatio > output.AbsorbRatio) { output = prop; } } return new ArmorProperties(output.Priority, output.AbsorbRatio, Integer.MAX_VALUE); }
public static float handleArmorProtection(EntityPlayer player, DamageSource source, float amount, ItemStack armor, BodyPart damaged, EntityEquipmentSlot slotDamaged) { if (source.isUnblockable()) { return amount; } Item armorItem = armor.getItem(); if (armorItem instanceof ISpecialArmor) { ISpecialArmor specialArmor = (ISpecialArmor) armorItem; float value = ArmorProperties.applyArmor(player, NonNullList.withSize(1, armor), source, amount); specialArmor.damageArmor(player, armor, source, (int) amount / 2, slotDamaged.getSlotIndex()); return value; } else { Multimap<String, AttributeModifier> modifiers = armor.getAttributeModifiers(slotDamaged); float toughnessMod = 1; for (AttributeModifier mod : modifiers.get(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName())) { if (mod.getOperation() == 0) { toughnessMod += mod.getAmount(); } else { toughnessMod *= mod.getAmount(); } } if (player instanceof EntityPlayerMP) { if (armor.attemptDamageItem((int) (amount / 2), player.world.rand, (EntityPlayerMP) player)) { armor.setCount(0); } } return amount * (1 / toughnessMod); } }
@Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { if(getMaterial() == MedievalArmourMaterial.GUILDED) { if(source != null && source.getEntity() != null) { if(source.getEntity() instanceof EntityLivingBase) { EntityLivingBase mob = (EntityLivingBase)source.getEntity(); if(shouldSilverHurt(mob)) { float deflect = (float)damage * (source.isProjectile() ? 0.5F : 1.0F); mob.attackEntityFrom(DamageSource.magic, deflect); } } } if(source.isMagicDamage() || source == DamageSource.wither) { if(damage <= 1.0F && player.getRNG().nextFloat()*2 < AD.protection) { damage = 0; } damage /= (2 * AD.protection); } } double AC = (double)damageReduceAmount; if(source.isProjectile()) { AC *= AD.projResist; } else if(source.isFireDamage()) { AC *= AD.fireResist; } else if(source.isExplosion()) { AC *= AD.expResist; } else if(source == DamageSourceAP.blunt) { AC *= AD.bluntResist; } else { AC *= AD.protection; } if(source != DamageSourceAP.blunt && source.isUnblockable()) { AC = 0; } if(source == DamageSource.fall) { if(getMaterial() == MedievalArmourMaterial.STEALTH) { AC += 4; } else { AC *= AD.fallResist; } } if(!player.worldObj.isRemote && MineFantasyBase.isDebug()) { System.out.println("AC: " + AC); } float m = (float) ((getMaxDamage() + 1 - armor.getItemDamage()) * AC); return new ArmorProperties(0, AC / 25D, (int)m); }
@Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { if(getMaterial() == EnumArmourMF.GUILDED) { if(source != null && source.getEntity() != null) { if(source.getEntity() instanceof EntityLivingBase) { EntityLivingBase mob = (EntityLivingBase)source.getEntity(); if(shouldSilverHurt(mob)) { float deflect = (float)damage * (source.isProjectile() ? 0.5F : 1.0F); mob.attackEntityFrom(DamageSource.magic, deflect); } } } if(source.isMagicDamage() || source == DamageSource.wither) { if(damage <= 1.0F && player.getRNG().nextFloat()*2 < AD.protection) { damage = 0; } damage /= (2 * AD.protection); } } int value = base.getDamageReductionAmount(armorType); double AC = (double)value * material.armourRating; if(source.isProjectile()) { AC *= AD.projResist; } else if(source.isFireDamage()) { AC *= AD.fireResist; } else if(source.isExplosion()) { AC *= AD.expResist; } else if(source == DamageSourceAP.blunt) { AC *= AD.bluntResist; } else { AC *= AD.protection; } if(source != DamageSourceAP.blunt && source.isUnblockable()) { AC = 0; } if(source == DamageSource.fall) { if(getMaterial() == EnumArmourMF.STEALTH) { AC += 4; } else { AC *= AD.fallResist; } } if(!player.worldObj.isRemote && MineFantasyBase.isDebug()) { System.out.println("AC: " + AC); } float m = (float) ((getMaxDamage() + 1 - armor.getItemDamage()) * AC); double maxRatio = 0.99D / 10 * this.base.getDamageReductionAmount(armorType); double ratio = Math.min(AC / 25D, maxRatio); return new ArmorProperties(0, AC / 25D, (int)m); }
@Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, ArmourSlot slot) { IModularItem item = (IModularItem) armor.getItem(); if (EnergyUtil.isEmpty(armor)) { return new ArmorProperties(0, 0, 0); } if (this.shouldDefend(player, armor, source, damage, slot)) { item.damageArmour(armor, (int) (this.getEnergyPerDamage(armor) * damage)); float temp = maxProtection * protection.get(armor).getPercentage() * (limitDamage(player, armor, source, damage, slot) / 100F); return new ArmorProperties(0, temp / 100, Integer.MAX_VALUE); } return new ArmorProperties(0, 0, 0); }
@Override public ArmorProperties getProperties(EntityLivingBase attacker, ItemStack armor, DamageSource source, double damage, ArmourSlot slot) { return null; }
/** * Called to check what the armour should protect against. * * @param attacker * @param armour * @param source * @param damage * @param armourSlot * @return ArmorProperties describing what the Armour should protect against * when this upgrade is equiped. */ ArmorProperties getProperties(EntityLivingBase attacker, ItemStack armour, DamageSource source, double damage, ArmourSlot armourSlot);
/** * Get the properties for the armour. * * @param player * @param stack * @param source * @param damage * @param slot * @return The properties detailing the reaction on hit. */ public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot);