public void func_151367_b(EntityLivingBase p_151367_1_, Entity p_151367_2_, int p_151367_3_) { Random random = p_151367_1_.getRNG(); ItemStack itemstack = EnchantmentHelper.func_92099_a(Enchantment.thorns, p_151367_1_); if (func_92094_a(p_151367_3_, random)) { p_151367_2_.attackEntityFrom( DamageSource.causeThornsDamage(p_151367_1_), (float) func_92095_b(p_151367_3_, random)); p_151367_2_.playSound("damage.thorns", 0.5F, 1.0F); if (itemstack != null) { itemstack.damageItem(3, p_151367_1_); } } else if (itemstack != null) { itemstack.damageItem(1, p_151367_1_); } }
public static void func_92096_a( Entity par0Entity, EntityLivingBase par1EntityLivingBase, Random par2Random) { int i = EnchantmentHelper.func_92098_i(par1EntityLivingBase); ItemStack itemstack = EnchantmentHelper.func_92099_a(Enchantment.thorns, par1EntityLivingBase); if (func_92094_a(i, par2Random)) { par0Entity.attackEntityFrom( DamageSource.causeThornsDamage(par1EntityLivingBase), (float) func_92095_b(i, par2Random)); par0Entity.playSound("damage.thorns", 0.5F, 1.0F); if (itemstack != null) { itemstack.damageItem(3, par1EntityLivingBase); } } else if (itemstack != null) { itemstack.damageItem(1, par1EntityLivingBase); } }
@SubscribeEvent public void onAttackEntity(AttackEntityEvent event) { if (event.entityLiving.worldObj.isRemote) return; EntityLivingBase attacker = event.entityLiving; EntityPlayer player = event.entityPlayer; Entity target = event.target; ItemStack stack = attacker.getEquipmentInSlot(0); if (stack != null && stack.getItem().onLeftClickEntity(stack, player, target)) return; if (target.canAttackWithItem()) { if (!target.hitByEntity(target)) { float damageAmount = TFC_MobData.STEVE_DAMAGE; if (stack != null) { damageAmount = (float) player .getEntityAttribute(SharedMonsterAttributes.attackDamage) .getAttributeValue(); // player.addChatMessage("Damage: " + i); if (damageAmount == 1.0f) { damageAmount = TFC_MobData.STEVE_DAMAGE; // i = player.inventory.getCurrentItem().getItem().getDamageVsEntity(target, // player.inventory.getCurrentItem()); } } if (player.isPotionActive(Potion.damageBoost)) damageAmount += 3 << player.getActivePotionEffect(Potion.damageBoost).getAmplifier(); if (player.isPotionActive(Potion.weakness)) damageAmount -= 2 << player.getActivePotionEffect(Potion.weakness).getAmplifier(); int knockback = 0; float enchantmentDamage = 0; if (target instanceof EntityLiving) { enchantmentDamage = EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLiving) target); knockback += EnchantmentHelper.getKnockbackModifier(player, (EntityLiving) target); } if (player.isSprinting()) ++knockback; if (damageAmount > 0 || enchantmentDamage > 0) { boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null && target instanceof EntityLiving; if (criticalHit && damageAmount > 0) damageAmount += event.entity.worldObj.rand.nextInt((int) (damageAmount / 2 + 2)); damageAmount += enchantmentDamage; boolean onFire = false; int fireAspect = EnchantmentHelper.getFireAspectModifier(player); if (target instanceof EntityLiving && fireAspect > 0 && !target.isBurning()) { onFire = true; target.setFire(1); } boolean entityAttacked = target.attackEntityFrom(DamageSource.causePlayerDamage(player), damageAmount); if (entityAttacked) { if (knockback > 0) { target.addVelocity( -MathHelper.sin(player.rotationYaw * (float) Math.PI / 180.0F) * knockback * 0.5F, 0.1D, MathHelper.cos(player.rotationYaw * (float) Math.PI / 180.0F) * knockback * 0.5F); player.motionX *= 0.6D; player.motionZ *= 0.6D; player.setSprinting(false); } if (criticalHit) player.onCriticalHit(target); if (enchantmentDamage > 0) player.onEnchantmentCritical(target); if (damageAmount >= 18) player.triggerAchievement(AchievementList.overkill); player.setLastAttacker(target); if (target instanceof EntityLiving) target.attackEntityFrom(DamageSource.causeThornsDamage(attacker), damageAmount); } ItemStack itemstack = player.getCurrentEquippedItem(); Object object = target; if (target instanceof EntityDragonPart) { IEntityMultiPart ientitymultipart = ((EntityDragonPart) target).entityDragonObj; if (ientitymultipart instanceof EntityLiving) object = ientitymultipart; } if (itemstack != null && object instanceof EntityLiving) { itemstack.hitEntity((EntityLiving) object, player); if (itemstack.stackSize <= 0) player.destroyCurrentEquippedItem(); } if (target instanceof EntityLivingBase) { player.addStat(StatList.damageDealtStat, Math.round(damageAmount * 10.0f)); if (fireAspect > 0 && entityAttacked) target.setFire(fireAspect * 4); else if (onFire) target.extinguish(); } player.addExhaustion(0.3F); } } } event.setCanceled(true); }