示例#1
0
  /** Called when the entity is attacked. */
  public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) {
    if (this.capabilities.disableDamage && !par1DamageSource.canHarmInCreative()) {
      return false;
    } else {
      this.entityAge = 0;

      if (this.getHealth() <= 0) {
        return false;
      } else {
        if (this.isPlayerSleeping() && !this.worldObj.isRemote) {
          this.wakeUpPlayer(true, true, false);
        }

        Entity var3 = par1DamageSource.getEntity();

        if (var3 instanceof EntityMob || var3 instanceof EntityArrow) {
          if (this.worldObj.difficultySetting == 0) {
            par2 = 0;
          }

          if (this.worldObj.difficultySetting == 1) {
            par2 = par2 / 2 + 1;
          }

          if (this.worldObj.difficultySetting == 3) {
            par2 = par2 * 3 / 2;
          }
        }

        if (par2 == 0) {
          return false;
        } else {
          Entity var4 = var3;

          if (var3 instanceof EntityArrow && ((EntityArrow) var3).shootingEntity != null) {
            var4 = ((EntityArrow) var3).shootingEntity;
          }

          if (var4 instanceof EntityLiving) {
            this.alertWolves((EntityLiving) var4, false);
          }

          this.addStat(StatList.damageTakenStat, par2);
          return super.attackEntityFrom(par1DamageSource, par2);
        }
      }
    }
  }
 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);
 }