@SubscribeEvent public void onPlayerDamaged(LivingAttackEvent event){ event.getEntityLiving().getEntityWorld(); EntityLivingBase attacked = event.getEntityLiving(); DamageSource source = event.getSource(); int pureCount = getArmorCount(attacked, "pure"); if(getArmorCount(attacked, "red") == 4 || pureCount == 4){ if(source == DamageSource.HOT_FLOOR){ event.setCanceled(true); } } if(getArmorCount(attacked, "dark") == 4 || pureCount == 4){ if(source.getSourceOfDamage() !=null){ Entity toAttack = source.getSourceOfDamage(); toAttack.attackEntityFrom(DamageSource.causeThornsDamage(attacked), EnchantmentThorns.getDamage(5, EntityUtil.rand)); if(toAttack instanceof EntityLivingBase){ EntityLivingBase living = (EntityLivingBase)toAttack; if(EntityUtil.rand.nextInt(10) == 0){ living.addPotionEffect(new PotionEffect(MobEffects.WITHER, MathHelper.getInt(EntityUtil.rand, 20*3, 20*6), 0)); } } } } /*if(source == DamageSource.FALL){ BlockPos pos = new BlockPos(attacked).down(); IBlockState state = world.getBlockState(pos); if (state.getBlock() instanceof BlockLiquid && attacked.posY > pos.getY() + 0.9 && !(world.getBlockState(pos.up()).getBlock().getMaterial(world.getBlockState(pos.up())) == Material.WATER)) { if(UpgradeItemRecipe.isWaterWalking(attacked.getItemStackFromSlot(EntityEquipmentSlot.FEET))){ world.playSound(null, pos, SoundEvents.ENTITY_PLAYER_SPLASH, SoundCategory.PLAYERS, 1.0F, 1.0F); event.setCanceled(true); } } }*/ }
@Override public boolean attackEntityAsMob(Entity enemy) { timeUntilSit = 100; jawMove = 10; float i = getBiteDamage(enemy); if(armour[0] != null) { if(armour[0].getItem() instanceof ItemHoundWeapon) { if(enemy instanceof EntityLiving) ((ItemHoundWeapon)armour[0].getItem()).hitEntity(armour[0], (EntityLiving)enemy, this); } if (enemy instanceof EntityLiving) { i += EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLiving)enemy); } } if(enemy.attackEntityFrom(DamageSource.causeMobDamage(this), i)) { xp += (int)i; return true; } if (enemy instanceof EntityLiving) { EnchantmentThorns.func_92096_a(this, (EntityLiving)enemy, this.rand); int l = EnchantmentHelper.getFireAspectModifier(this); if (l > 0 && !enemy.isBurning()) { enemy.setFire(l); } } return false; }
public boolean func_70652_k(Entity p_70652_1_) { float var2 = (float)this.func_110148_a(SharedMonsterAttributes.field_111264_e).func_111126_e(); int var3 = 0; if(p_70652_1_ instanceof EntityLivingBase) { var2 += EnchantmentHelper.func_77512_a(this, (EntityLivingBase)p_70652_1_); var3 += EnchantmentHelper.func_77507_b(this, (EntityLivingBase)p_70652_1_); } boolean var4 = p_70652_1_.func_70097_a(DamageSource.func_76358_a(this), var2); if(var4) { if(var3 > 0) { p_70652_1_.func_70024_g((double)(-MathHelper.func_76126_a(this.field_70177_z * 3.1415927F / 180.0F) * (float)var3 * 0.5F), 0.1D, (double)(MathHelper.func_76134_b(this.field_70177_z * 3.1415927F / 180.0F) * (float)var3 * 0.5F)); this.field_70159_w *= 0.6D; this.field_70179_y *= 0.6D; } int var5 = EnchantmentHelper.func_90036_a(this); if(var5 > 0) { p_70652_1_.func_70015_d(var5 * 4); } if(p_70652_1_ instanceof EntityLivingBase) { EnchantmentThorns.func_92096_a(this, (EntityLivingBase)p_70652_1_, this.field_70146_Z); } } return var4; }
public boolean attackEntityAsMob(Entity par1Entity) { float f = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); int i = 0; if (par1Entity instanceof EntityLivingBase) { f += EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLivingBase)par1Entity); i += EnchantmentHelper.getKnockbackModifier(this, (EntityLivingBase)par1Entity); } boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), f); if (flag) { if (i > 0) { par1Entity.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) { par1Entity.setFire(j * 4); } if (par1Entity instanceof EntityLivingBase) { EnchantmentThorns.func_92096_a(this, (EntityLivingBase)par1Entity, this.rand); } } return flag; }
@Override public boolean attackEntityAsMob(Entity tar) { if(!this.canEntityBeSeen(tar))return false; float f = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() * attackMod; int i = 0; if (tar instanceof EntityLivingBase) { f += EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLivingBase)tar); i += EnchantmentHelper.getKnockbackModifier(this, (EntityLivingBase)tar); } boolean flag = tar.attackEntityFrom(DamageSource.causeMobDamage(this), f); if(isTitan) { if(!worldObj.isRemote && rand.nextInt(getStrongChance()) == 0) { worldObj.createExplosion(this, tar.posX, tar.posY, tar.posZ, rand.nextFloat()*0.5F + 0.5F, true); } } if (flag) { if (i > 0) { tar.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) { tar.setFire(j * 4); } if (tar instanceof EntityLivingBase) { EnchantmentThorns.func_92096_a(this, (EntityLivingBase)tar, this.rand); } } return flag; }
public boolean attackEntityAsMob(Entity target) { float var2 = this.getAttackStrength(target); if (this.isPotionActive(Potion.damageBoost)) { var2 += 3 << this.getActivePotionEffect(Potion.damageBoost).getAmplifier(); } if (this.isPotionActive(Potion.weakness)) { var2 -= 2 << this.getActivePotionEffect(Potion.weakness).getAmplifier(); } int var3 = 0; if (target instanceof EntityLiving) { var2 += EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLiving)target); var3 += EnchantmentHelper.getKnockbackModifier(this, (EntityLiving)target); } boolean var4 = target.attackEntityFrom(DamageSource.causeMobDamage(this), var2); if (var4) { if (var3 > 0) { target.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)var3 * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)var3 * 0.5F)); this.motionX *= 0.6D; this.motionZ *= 0.6D; } int var5 = EnchantmentHelper.getFireAspectModifier(this); if (var5 > 0) { target.setFire(var5 * 4); } if (target instanceof EntityLiving) { EnchantmentThorns.func_92096_a(this, (EntityLiving)target, this.rand); } } return var4; }
@Override public boolean attackEntityAsMob(Entity par1Entity) { int i = this.getAttackStrength(par1Entity); if (this.isPotionActive(Potion.damageBoost)) { i += 3 << this.getActivePotionEffect(Potion.damageBoost).getAmplifier(); } if (this.isPotionActive(Potion.weakness)) { i -= 2 << this.getActivePotionEffect(Potion.weakness).getAmplifier(); } int j = 0; if (par1Entity instanceof EntityLiving) { i += EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLiving)par1Entity); j += EnchantmentHelper.getKnockbackModifier(this, (EntityLiving)par1Entity); } boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), i); if (flag) { if (j > 0) { this.heal(5); par1Entity.addVelocity(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * j * 0.5F, 0.1D, MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * j * 0.5F); this.motionX *= 0.6D; this.motionZ *= 0.6D; } int k = EnchantmentHelper.getFireAspectModifier(this); if (k > 0) { par1Entity.setFire(k * 4); } if (par1Entity instanceof EntityLiving) { EnchantmentThorns.func_92096_a(this, (EntityLiving)par1Entity, this.rand); } } return flag; }