예제 #1
0
  public void a(DamageSource damagesource) {
    super.a(damagesource);
    double d0 = this.motX * this.motX + this.motZ * this.motZ;

    if (!damagesource.c()) {
      this.a(new ItemStack(Block.TNT, 1), 0.0F);
    }

    if (damagesource.m() || damagesource.c() || d0 >= 0.009999999776482582D) {
      this.c(d0);
    }
  }
예제 #2
0
  public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
      return false;
    } else if (this.world.isStatic) {
      return false;
    } else {
      this.aV = 0;
      if (this.getHealth() <= 0.0F) {
        return false;
      } else if (damagesource.m() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) {
        return false;
      } else {
        if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK)
            && this.getEquipment(4) != null) {
          this.getEquipment(4).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
          f *= 0.75F;
        }

        this.aG = 1.5F;
        boolean flag = true;

        // CraftBukkit start
        EntityDamageEvent event = CraftEventFactory.handleEntityDamageEvent(this, damagesource, f);
        if (event != null) {
          if (event.isCancelled()) {
            return false;
          }
          f = (float) event.getDamage();
        }
        // CraftBukkit end

        if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
          if (f <= this.lastDamage) {
            return false;
          }

          this.d(damagesource, f - this.lastDamage);
          this.lastDamage = f;
          flag = false;
        } else {
          this.lastDamage = f;
          this.ax = this.getHealth();
          this.noDamageTicks = this.maxNoDamageTicks;
          this.d(damagesource, f);
          this.hurtTicks = this.az = 10;
        }

        this.aA = 0.0F;
        Entity entity = damagesource.getEntity();

        if (entity != null) {
          if (entity instanceof EntityLiving) {
            this.b((EntityLiving) entity);
          }

          if (entity instanceof EntityHuman) {
            this.lastDamageByPlayerTime = 100;
            this.killer = (EntityHuman) entity;
          } else if (entity instanceof EntityWolf) {
            EntityWolf entitywolf = (EntityWolf) entity;

            if (entitywolf.isTamed()) {
              this.lastDamageByPlayerTime = 100;
              this.killer = null;
            }
          }
        }

        if (flag) {
          this.world.broadcastEntityEffect(this, (byte) 2);
          if (damagesource != DamageSource.DROWN) {
            this.K();
          }

          if (entity != null) {
            double d0 = entity.locX - this.locX;

            double d1;

            for (d1 = entity.locZ - this.locZ;
                d0 * d0 + d1 * d1 < 1.0E-4D;
                d1 = (Math.random() - Math.random()) * 0.01D) {
              d0 = (Math.random() - Math.random()) * 0.01D;
            }

            this.aA = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw;
            this.a(entity, f, d0, d1);
          } else {
            this.aA = (float) ((int) (Math.random() * 2.0D) * 180);
          }
        }

        if (this.getHealth() <= 0.0F) {
          if (flag) {
            this.makeSound(this.aP(), this.ba(), this.bb());
          }

          this.die(damagesource);
        } else if (flag) {
          this.makeSound(this.aO(), this.ba(), this.bb());
        }

        return true;
      }
    }
  }