/**
   * This function is used when two same-species animals in 'love mode' breed to generate the new
   * baby animal.
   */
  public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable) {
    EntityWolf var2 = new EntityWolf(this.worldObj);
    String var3 = this.getOwnerName();

    if (var3 != null && var3.trim().length() > 0) {
      var2.setOwner(var3);
      var2.setTamed(true);
    }

    return var2;
  }
 /** Returns true if the mob is currently able to mate with the specified mob. */
 public boolean canMateWith(EntityAnimal par1EntityAnimal) {
   if (par1EntityAnimal == this) {
     return false;
   } else if (!this.isTamed()) {
     return false;
   } else if (!(par1EntityAnimal instanceof EntityWolf)) {
     return false;
   } else {
     EntityWolf var2 = (EntityWolf) par1EntityAnimal;
     return !var2.isTamed()
         ? false
         : (var2.isSitting() ? false : this.isInLove() && var2.isInLove());
   }
 }
Example #3
0
  protected void a(EntityLiving entityliving, boolean flag) {
    if (!(entityliving instanceof EntityCreeper) && !(entityliving instanceof EntityGhast)) {
      if (entityliving instanceof EntityWolf) {
        EntityWolf entitywolf = (EntityWolf) entityliving;

        if (entitywolf.isTamed() && this.name.equals(entitywolf.getOwnerName())) {
          return;
        }
      }

      if (!(entityliving instanceof EntityHuman) || this.C()) {
        List list =
            this.world.a(
                EntityWolf.class,
                AxisAlignedBB.b(
                        this.locX,
                        this.locY,
                        this.locZ,
                        this.locX + 1.0D,
                        this.locY + 1.0D,
                        this.locZ + 1.0D)
                    .grow(16.0D, 4.0D, 16.0D));
        Iterator iterator = list.iterator();

        while (iterator.hasNext()) {
          Entity entity = (Entity) iterator.next();
          EntityWolf entitywolf1 = (EntityWolf) entity;

          if (entitywolf1.isTamed()
              && entitywolf1.I() == null
              && this.name.equals(entitywolf1.getOwnerName())
              && (!flag || !entitywolf1.isSitting())) {
            entitywolf1.setSitting(false);
            entitywolf1.setTarget(entityliving);
          }
        }
      }
    }
  }
Example #4
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;
      }
    }
  }
Example #5
0
 protected float func_25004_a(EntityWolf p_25004_1_, float p_25004_2_) {
   return p_25004_1_.func_25037_z();
 }