private double getAttribute(EntityPlayer player, ItemStack stack, Multimap<String, AttributeModifier> map, String key) { if(player == null) // apparently this can happen return 0; Collection<AttributeModifier> collection = map.get(key); if(collection.isEmpty()) return 0; AttributeModifier attributemodifier = collection.iterator().next(); double d0 = attributemodifier.getAmount(); boolean flag = false; if(key.equals("generic.attackDamage")) { d0 += player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue(); d0 += (double) EnchantmentHelper.getModifierForCreature(stack, EnumCreatureAttribute.UNDEFINED); } else if(key.equals("generic.attackSpeed")) d0 += player.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue(); return d0; }
d0 += EnchantmentHelper.getModifierForCreature(stack, EnumCreatureAttribute.UNDEFINED);
/** * Calculates the ranged attack damage * * @return the attack damage */ private double getRangedAttackDamage() { if (worker.getCitizenData() != null) { int enchantDmg = 0; if (Configurations.gameplay.rangerEnchants) { final ItemStack heldItem = worker.getHeldItem(EnumHand.MAIN_HAND); // Normalize to +1 dmg enchantDmg += EnchantmentHelper.getModifierForCreature(heldItem, target.getCreatureAttribute()) / 2.5; enchantDmg += EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, heldItem); } return (RANGER_BASE_DMG + getLevelDamage() + enchantDmg) * Configurations.gameplay.rangerDamageMult; } return RANGER_BASE_DMG * Configurations.gameplay.rangerDamageMult; }
float f1 = EnchantmentHelper.getModifierForCreature(held, (ent).getCreatureAttribute()); if (ent.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer.get()), dmgVal + f1)) {
weaponAttackDamage = EnchantmentHelper.getModifierForCreature(player.getHeldItem(EnumHand.MAIN_HAND), ((EntityLivingBase)target).getCreatureAttribute()); weaponAttackDamage = EnchantmentHelper.getModifierForCreature(player.getHeldItem(EnumHand.MAIN_HAND), EnumCreatureAttribute.UNDEFINED);
private int getAttackDamage() { if (worker.getCitizenData() != null) { int addDmg = 0; final ItemStack heldItem = worker.getHeldItem(EnumHand.MAIN_HAND); if (ItemStackUtils.doesItemServeAsWeapon(heldItem)) { if (heldItem.getItem() instanceof ItemSword) { addDmg += ((ItemSword) heldItem.getItem()).getAttackDamage(); } else { addDmg += TinkersWeaponHelper.getDamage(heldItem); } addDmg += EnchantmentHelper.getModifierForCreature(heldItem, target.getCreatureAttribute()) / 2.5; } addDmg += getLevelDamage(); return (int) ((BASE_PHYSICAL_DAMAGE + addDmg) * Configurations.gameplay.rangerDamageMult); } return (int) (BASE_PHYSICAL_DAMAGE * Configurations.gameplay.knightDamageMult); } }
public boolean attackEntityAsMob(Entity entity) { float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue(); int i = 0; if (entity instanceof EntityLivingBase) { f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) entity).getCreatureAttribute()); i += EnchantmentHelper.getKnockbackModifier(this); } boolean flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), f); if (flag) { if (i > 0) { entity.addVelocity((double) (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F)); this.motionX *= 0.6D; this.motionZ *= 0.6D; } int j = EnchantmentHelper.getFireAspectModifier(this); if (j > 0) { entity.setFire(j * 4); } this.applyEnchantments(this, entity); } return flag; }
@Override public boolean attackEntityAsMob(Entity entityIn) { float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue(); int i = 0; if (entityIn instanceof EntityLivingBase) { f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) entityIn).getCreatureAttribute()); i += EnchantmentHelper.getKnockbackModifier(this); } boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f); if (flag) { if (i > 0) { entityIn.addVelocity((double) (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F)); this.motionX *= 0.6D; this.motionZ *= 0.6D; } int j = EnchantmentHelper.getFireAspectModifier(this); if (j > 0) { entityIn.setFire(j * 4); } this.applyEnchantments(this, entityIn); } return flag; }
public boolean attackEntityAsMob(Entity entity) { float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue(); int i = 0; if (entity instanceof EntityLivingBase) { f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) entity).getCreatureAttribute()); i += EnchantmentHelper.getKnockbackModifier(this); } boolean flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), f); if (flag) { if (i > 0) { entity.addVelocity((double) (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F)); this.motionX *= 0.6D; this.motionZ *= 0.6D; } int j = EnchantmentHelper.getFireAspectModifier(this); if (j > 0) { entity.setFire(j * 4); } this.applyEnchantments(this, entity); if (entity instanceof EntityLivingBase) { this.attackedEntityAsMob((EntityLivingBase) entity); } } return flag; }
f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) attackedEntity).getCreatureAttribute()); i += EnchantmentHelper.getKnockbackModifier(this);
f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute()); i += EnchantmentHelper.getKnockbackModifier(this);
damage += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) target).getCreatureAttribute()); knockback += EnchantmentHelper.getKnockbackModifier(this);
f1 = EnchantmentHelper.getModifierForCreature(player.getHeldItemMainhand(), ((EntityLivingBase) target).getCreatureAttribute()); }else{ f1 = EnchantmentHelper.getModifierForCreature(player.getHeldItemMainhand(), EnumCreatureAttribute.UNDEFINED);