コード例 #1
0
 protected void damageEntity(DamageSource damagesource, int i) {
   if (!damagesource.isUnblockable() && isBlocking()) {
     i = 1 + i >> 1;
   }
   i = applyArmorCalculations(damagesource, i);
   i = applyPotionDamageCalculations(damagesource, i);
   addExhaustion(damagesource.getHungerDamage());
   health -= i;
 }
コード例 #2
0
 protected void func_70227_a(MovingObjectPosition p_70227_1_) {
   if (!field_70170_p.field_72995_K) {
     if (p_70227_1_.field_72308_g != null) {
       p_70227_1_.field_72308_g.func_70097_a(DamageSource.func_76362_a(this, field_70235_a), 6);
     }
     field_70170_p.func_72885_a(null, field_70165_t, field_70163_u, field_70161_v, 1.0F, true);
     func_70106_y();
   }
 }
コード例 #3
0
 public boolean attackEntityFrom(DamageSource damagesource, int i) {
   Entity entity = damagesource.getEntity();
   if (entity != null
       && entity != this
       && (entity instanceof EntityPlayer)
       && ((EntityPlayer) entity).username == getBotOwner()) {
     i = 20;
   }
   return super.attackEntityFrom(damagesource, i);
 }
コード例 #4
0
 public boolean func_70097_a(DamageSource p_70097_1_, int p_70097_2_) {
   func_70018_K();
   if (p_70097_1_.func_76346_g() != null) {
     Vec3 vec3 = p_70097_1_.func_76346_g().func_70040_Z();
     if (vec3 != null) {
       field_70159_w = vec3.field_72450_a;
       field_70181_x = vec3.field_72448_b;
       field_70179_y = vec3.field_72449_c;
       field_70232_b = field_70159_w * 0.10000000000000001D;
       field_70233_c = field_70181_x * 0.10000000000000001D;
       field_70230_d = field_70179_y * 0.10000000000000001D;
     }
     if (p_70097_1_.func_76346_g() instanceof EntityLiving) {
       field_70235_a = (EntityLiving) p_70097_1_.func_76346_g();
     }
     return true;
   } else {
     return false;
   }
 }
コード例 #5
0
 public void die(DamageSource damagesource) {
   if (village != null) {
     Entity entity = damagesource.getEntity();
     if (entity != null) {
       if (entity instanceof EntityHuman) village.a(entity.getName(), -2);
       else if (entity instanceof IMonster) village.h();
     } else if (entity == null) {
       EntityHuman entityhuman = world.findNearbyPlayer(this, 16D);
       if (entityhuman != null) village.h();
     }
   }
   super.die(damagesource);
 }
コード例 #6
0
 public boolean attackEntityFrom(DamageSource damagesource, int i) {
   if (capabilities.disableDamage && !damagesource.canHarmInCreative()) {
     return false;
   }
   entityAge = 0;
   if (getEntityHealth() <= 0) {
     return false;
   }
   if (isPlayerSleeping() && !worldObj.multiplayerWorld) {
     wakeUpPlayer(true, true, false);
   }
   Entity entity = damagesource.getEntity();
   if ((entity instanceof EntityMob) || (entity instanceof EntityArrow)) {
     if (worldObj.difficultySetting == 0) {
       i = 0;
     }
     if (worldObj.difficultySetting == 1) {
       i = i / 2 + 1;
     }
     if (worldObj.difficultySetting == 3) {
       i = (i * 3) / 2;
     }
   }
   if (i == 0) {
     return false;
   }
   Entity entity1 = entity;
   if ((entity1 instanceof EntityArrow) && ((EntityArrow) entity1).shootingEntity != null) {
     entity1 = ((EntityArrow) entity1).shootingEntity;
   }
   if (entity1 instanceof EntityLiving) {
     alertWolves((EntityLiving) entity1, false);
   }
   addStat(StatList.damageTakenStat, i);
   return super.attackEntityFrom(damagesource, i);
 }
コード例 #7
0
 public boolean attackEntityFrom(DamageSource damagesource, int i) {
   if (ticksOfInvuln > 0) {
     return false;
   }
   if (!mcServer.pvpOn && (damagesource instanceof EntityDamageSource)) {
     Entity entity = damagesource.getEntity();
     if (entity instanceof EntityPlayer) {
       return false;
     }
     if (entity instanceof EntityArrow) {
       EntityArrow entityarrow = (EntityArrow) entity;
       if (entityarrow.shootingEntity instanceof EntityPlayer) {
         return false;
       }
     }
   }
   return super.attackEntityFrom(damagesource, i);
 }
コード例 #8
0
 protected boolean attackEntityAsMob(Entity entity) {
   return entity.attackEntityFrom(DamageSource.causeMobDamage(this), 8);
 }
コード例 #9
0
 public void attackTargetEntityWithCurrentItem(Entity entity) {
   int i = inventory.getDamageVsEntity(entity);
   if (isPotionActive(Potion.damageBoost)) {
     i += 3 << getActivePotionEffect(Potion.damageBoost).getAmplifier();
   }
   if (isPotionActive(Potion.weakness)) {
     i -= 2 << getActivePotionEffect(Potion.weakness).getAmplifier();
   }
   int j = 0;
   int k = 0;
   if (entity instanceof EntityLiving) {
     k = EnchantmentHelper.getEnchantmentModifierLiving(inventory, (EntityLiving) entity);
     j += EnchantmentHelper.getKnockbackModifier(inventory, (EntityLiving) entity);
   }
   if (isSprinting()) {
     j++;
   }
   if (i > 0 || k > 0) {
     boolean flag =
         fallDistance > 0.0F
             && !onGround
             && !isOnLadder()
             && !isInWater()
             && !isPotionActive(Potion.blindness)
             && ridingEntity == null
             && (entity instanceof EntityLiving);
     if (flag) {
       i += rand.nextInt(i / 2 + 2);
     }
     i += k;
     boolean flag1 = entity.attackEntityFrom(DamageSource.causePlayerDamage(this), i);
     if (flag1) {
       if (j > 0) {
         entity.addVelocity(
             -MathHelper.sin((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F,
             0.10000000000000001D,
             MathHelper.cos((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F);
         motionX *= 0.59999999999999998D;
         motionZ *= 0.59999999999999998D;
         setSprinting(false);
       }
       if (flag) {
         onCriticalHit(entity);
       }
       if (k > 0) {
         func_40183_c(entity);
       }
       if (i >= 18) {
         triggerAchievement(AchievementList.overkill);
       }
     }
     ItemStack itemstack = getCurrentEquippedItem();
     if (itemstack != null && (entity instanceof EntityLiving)) {
       itemstack.hitEntity((EntityLiving) entity, this);
       if (itemstack.stackSize <= 0) {
         itemstack.onItemDestroyedByUse(this);
         destroyCurrentEquippedItem();
       }
     }
     if (entity instanceof EntityLiving) {
       if (entity.isEntityAlive()) {
         alertWolves((EntityLiving) entity, true);
       }
       addStat(StatList.damageDealtStat, i);
       int l = EnchantmentHelper.getFireAspectModifier(inventory, (EntityLiving) entity);
       if (l > 0) {
         entity.setFire(l * 4);
       }
     }
     addExhaustion(0.3F);
   }
 }
コード例 #10
0
 public void onDeath(DamageSource damagesource) {
   mcServer.configManager.sendPacketToAllPlayers(new Packet3Chat(damagesource.func_35075_a(this)));
   inventory.dropAllItems();
 }