public boolean func_75250_a() {
   if (field_75348_a.func_70874_b() >= 0) {
     return false;
   }
   List list =
       field_75348_a.field_70170_p.func_72872_a(
           field_75348_a.getClass(), field_75348_a.field_70121_D.func_72314_b(8D, 4D, 8D));
   EntityAnimal entityanimal = null;
   double d = 1.7976931348623157E+308D;
   Iterator iterator = list.iterator();
   do {
     if (!iterator.hasNext()) {
       break;
     }
     EntityAnimal entityanimal1 = (EntityAnimal) iterator.next();
     if (entityanimal1.func_70874_b() >= 0) {
       double d1 = field_75348_a.func_70068_e(entityanimal1);
       if (d1 <= d) {
         d = d1;
         entityanimal = entityanimal1;
       }
     }
   } while (true);
   if (entityanimal == null) {
     return false;
   }
   if (d < 9D) {
     return false;
   } else {
     field_75346_b = entityanimal;
     return true;
   }
 }
 public boolean func_75253_b() {
   if (!field_75346_b.func_70089_S()) {
     return false;
   }
   double d = field_75348_a.func_70068_e(field_75346_b);
   return d >= 9D && d <= 256D;
 }
Ejemplo n.º 3
0
 protected void attackEntity(Entity entity, float f) {
   if (entity instanceof EntityPlayer) {
     if (f < 3F) {
       double d = entity.posX - posX;
       double d1 = entity.posZ - posZ;
       rotationYaw = (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F;
       hasAttacked = true;
     }
     EntityPlayer entityplayer = (EntityPlayer) entity;
     if (entityplayer.getCurrentEquippedItem() == null
         || !func_40143_a(entityplayer.getCurrentEquippedItem())) {
       entityToAttack = null;
     }
   } else if (entity instanceof EntityAnimal) {
     EntityAnimal entityanimal = (EntityAnimal) entity;
     if (func_40146_g() > 0 && entityanimal.func_40146_g() < 0) {
       if ((double) f < 2.5D) {
         hasAttacked = true;
       }
     } else if (field_39004_a > 0 && entityanimal.field_39004_a > 0) {
       if (entityanimal.entityToAttack == null) {
         entityanimal.entityToAttack = this;
       }
       if (entityanimal.entityToAttack == this && (double) f < 3.5D) {
         entityanimal.field_39004_a++;
         field_39004_a++;
         field_39005_b++;
         if (field_39005_b % 4 == 0) {
           worldObj.spawnParticle(
               "heart",
               (posX + (double) (rand.nextFloat() * width * 2.0F)) - (double) width,
               posY + 0.5D + (double) (rand.nextFloat() * height),
               (posZ + (double) (rand.nextFloat() * width * 2.0F)) - (double) width,
               0.0D,
               0.0D,
               0.0D);
         }
         if (field_39005_b == 60) {
           func_40144_b((EntityAnimal) entity);
         }
       } else {
         field_39005_b = 0;
       }
     } else {
       field_39005_b = 0;
     }
   }
 }
Ejemplo n.º 4
0
  /** Called when the mob is falling. Calculates and applies fall damage. */
  protected void fall(float par1) {
    super.fall(par1);

    if (par1 > 5.0F && this.riddenByEntity instanceof EntityPlayer) {
      ((EntityPlayer) this.riddenByEntity).triggerAchievement(AchievementList.flyPig);
    }
  }
 protected void updatePlayerActionState() {
   if (onGround
       && (motionX > 0.050000000745058101D
           || motionZ > 0.050000000745058101D
           || motionX < -0.050000000745058101D
           || motionZ < -0.050000000745058101D)) {
     motionY = 0.44999998807907099D;
   }
   if (!h) {
     super.updatePlayerActionState();
   } else if (onGround) {
     h = false;
     worldObj.playSoundAtEntity(
         this, "rabbitland", 1.0F, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
     List list =
         worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(12D, 12D, 12D));
     for (int k = 0; k < list.size(); k++) {
       Entity entity = (Entity) list.get(k);
       if (entity instanceof EntityMob) {
         EntityMob entitymobs = (EntityMob) entity;
         entitymobs.playerToAttack = this;
       }
     }
   }
 }
Ejemplo n.º 6
0
  /** (abstract) Protected helper method to write subclass entity data to NBT. */
  public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
    super.writeEntityToNBT(par1NBTTagCompound);
    par1NBTTagCompound.setLong("Animal ID", animalID);
    par1NBTTagCompound.setInteger("Sex", sex);
    par1NBTTagCompound.setFloat("Size Modifier", size_mod);
    par1NBTTagCompound.setInteger("Hunger", hunger);
    par1NBTTagCompound.setBoolean("Pregnant", pregnant);
    par1NBTTagCompound.setFloat("MateSize", mateSizeMod);
    par1NBTTagCompound.setLong("ConceptionTime", conception);
    for (int i = 0; i < children.size(); i++) {
      String n = "Child" + i;
      par1NBTTagCompound.setLong(n, children.get(i).animalID);
    }
    if (mate != null) {
      par1NBTTagCompound.setLong("Mate number", mate.animalID);
    } else {
      par1NBTTagCompound.setLong("Mate number", -1);
    }
    if (isChild() && parent != null) {
      par1NBTTagCompound.setLong("Parent", parent.animalID);
    } else {
      par1NBTTagCompound.setLong("Parent", -1);
    }

    par1NBTTagCompound.setLong("AdultTime", adultTime);
    par1NBTTagCompound.setLong("BirthTime", birthTime);
  }
Ejemplo n.º 7
0
 public void handleHealthUpdate(byte par1) {
   if (par1 == 10) {
     this.sheepTimer = 40;
   } else {
     super.handleHealthUpdate(par1);
   }
 }
Ejemplo n.º 8
0
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  public void onLivingUpdate() {
    if (this.worldObj.isRemote) {
      this.sheepTimer = Math.max(0, this.sheepTimer - 1);
    }

    super.onLivingUpdate();
  }
Ejemplo n.º 9
0
  private void func_40144_b(EntityAnimal entityanimal) {
    EntityAnimal entityanimal1 = func_40145_a(entityanimal);
    if (entityanimal1 != null) {
      func_40142_a_(6000);
      entityanimal.func_40142_a_(6000);
      field_39004_a = 0;
      field_39005_b = 0;
      entityToAttack = null;
      entityanimal.entityToAttack = null;
      entityanimal.field_39005_b = 0;
      entityanimal.field_39004_a = 0;
      entityanimal1.func_40142_a_(-24000);
      entityanimal1.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
      for (int i = 0; i < 7; i++) {
        double d = rand.nextGaussian() * 0.02D;
        double d1 = rand.nextGaussian() * 0.02D;
        double d2 = rand.nextGaussian() * 0.02D;
        worldObj.spawnParticle(
            "heart",
            (posX + (double) (rand.nextFloat() * width * 2.0F)) - (double) width,
            posY + 0.5D + (double) (rand.nextFloat() * height),
            (posZ + (double) (rand.nextFloat() * width * 2.0F)) - (double) width,
            d,
            d1,
            d2);
      }

      worldObj.entityJoinedWorld(entityanimal1);
    }
  }
 public void func_75246_d() {
   if (--field_75345_d > 0) {
     return;
   } else {
     field_75345_d = 10;
     field_75348_a.func_70661_as().func_75497_a(field_75346_b, field_75347_c);
     return;
   }
 }
Ejemplo n.º 11
0
 @SideOnly(Side.CLIENT)
 public void handleHealthUpdate(byte par1) {
   if (par1 == 7) {
     this.playTameEffect(true);
   } else if (par1 == 6) {
     this.playTameEffect(false);
   } else {
     super.handleHealthUpdate(par1);
   }
 }
Ejemplo n.º 12
0
  /** (abstract) Protected helper method to write subclass entity data to NBT. */
  public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
    super.writeEntityToNBT(par1NBTTagCompound);

    if (this.getOwnerName() == null) {
      par1NBTTagCompound.setString("Owner", "");
    } else {
      par1NBTTagCompound.setString("Owner", this.getOwnerName());
    }

    par1NBTTagCompound.setBoolean("Sitting", this.isSitting());
  }
Ejemplo n.º 13
0
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readEntityFromNBT(par1NBTTagCompound);
    String var2 = par1NBTTagCompound.getString("Owner");

    if (var2.length() > 0) {
      this.setOwner(var2);
      this.setTamed(true);
    }

    this.aiSit.setSitting(par1NBTTagCompound.getBoolean("Sitting"));
    this.setSitting(par1NBTTagCompound.getBoolean("Sitting"));
  }
Ejemplo n.º 14
0
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readEntityFromNBT(par1NBTTagCompound);
    animalID = par1NBTTagCompound.getLong("Animal ID");
    sex = par1NBTTagCompound.getInteger("Sex");
    size_mod = par1NBTTagCompound.getFloat("Size Modifier");
    hunger = par1NBTTagCompound.getInteger("Hunger");
    pregnant = par1NBTTagCompound.getBoolean("Pregnant");
    mateSizeMod = par1NBTTagCompound.getFloat("MateSize");
    conception = par1NBTTagCompound.getLong("ConceptionTime");
    int m = 0;
    String n = "Child" + m;
    while (par1NBTTagCompound.hasKey(n)) {
      n = "Child" + m;
      m++;
      for (int j = 0; j < worldObj.loadedEntityList.size(); j++) {
        Entity k = (Entity) worldObj.loadedEntityList.get(j);
        if (k instanceof EntityAnimalTFC) {
          long i = par1NBTTagCompound.getLong(n);

          if (i == ((EntityAnimalTFC) k).animalID) {
            children.add((EntityAnimalTFC) k);
          }
        }
      }
    }
    long i = par1NBTTagCompound.getLong("Mate number");
    if (i != -1) {
      for (int j = 0; j < worldObj.loadedEntityList.size(); j++) {
        Entity k = (Entity) worldObj.loadedEntityList.get(j);
        if (k instanceof EntityAnimalTFC) {
          if (i == ((EntityAnimalTFC) k).animalID) {
            mate = (EntityAnimalTFC) k;
            break;
          }
        }
      }
    }
    if (isChild() && par1NBTTagCompound.getLong("Parent") != -1) {
      i = par1NBTTagCompound.getLong("Parent");
      for (int j = 0; j < worldObj.loadedEntityList.size(); j++) {
        Entity k = (Entity) worldObj.loadedEntityList.get(j);
        if (k instanceof EntityAnimalTFC) {
          if (i == ((EntityAnimalTFC) k).animalID) {
            parent = (EntityAnimalTFC) k;
            break;
          }
        }
      }
    }
    adultTime = par1NBTTagCompound.getLong("AdultTime");
    birthTime = par1NBTTagCompound.getLong("BirthTime");
  }
Ejemplo n.º 15
0
  private void func_75388_i() {
    EntityAnimal var1 = this.field_75390_d.func_70879_a(this.field_75391_e);
    if (var1 != null) {
      this.field_75390_d.func_70873_a(6000);
      this.field_75391_e.func_70873_a(6000);
      this.field_75390_d.func_70875_t();
      this.field_75391_e.func_70875_t();
      var1.func_70873_a(-24000);
      var1.func_70012_b(
          this.field_75390_d.field_70165_t,
          this.field_75390_d.field_70163_u,
          this.field_75390_d.field_70161_v,
          0.0F,
          0.0F);
      this.field_75394_a.func_72838_d(var1);
      Random var2 = this.field_75390_d.func_70681_au();

      for (int var3 = 0; var3 < 7; ++var3) {
        double var4 = var2.nextGaussian() * 0.02D;
        double var6 = var2.nextGaussian() * 0.02D;
        double var8 = var2.nextGaussian() * 0.02D;
        this.field_75394_a.func_72869_a(
            "heart",
            this.field_75390_d.field_70165_t
                + (double) (var2.nextFloat() * this.field_75390_d.field_70130_N * 2.0F)
                - (double) this.field_75390_d.field_70130_N,
            this.field_75390_d.field_70163_u
                + 0.5D
                + (double) (var2.nextFloat() * this.field_75390_d.field_70131_O),
            this.field_75390_d.field_70161_v
                + (double) (var2.nextFloat() * this.field_75390_d.field_70130_N * 2.0F)
                - (double) this.field_75390_d.field_70130_N,
            var4,
            var6,
            var8);
      }
    }
  }
Ejemplo n.º 16
0
  protected Entity findPlayerToAttack() {
    if (fleeingTick > 0) {
      return null;
    }
    float f = 8F;
    if (field_39004_a > 0) {
      List list = worldObj.getEntitiesWithinAABB(getClass(), boundingBox.addCoord(f, f, f));
      for (int i = 0; i < list.size(); i++) {
        EntityAnimal entityanimal = (EntityAnimal) list.get(i);
        if (entityanimal != this && entityanimal.field_39004_a > 0) {
          return entityanimal;
        }
      }

    } else if (func_40146_g() == 0) {
      List list1 =
          worldObj.getEntitiesWithinAABB(
              net.minecraft.src.EntityPlayer.class, boundingBox.addCoord(f, f, f));
      for (int j = 0; j < list1.size(); j++) {
        EntityPlayer entityplayer = (EntityPlayer) list1.get(j);
        if (entityplayer.getCurrentEquippedItem() != null
            && func_40143_a(entityplayer.getCurrentEquippedItem())) {
          return entityplayer;
        }
      }

    } else if (func_40146_g() > 0) {
      List list2 = worldObj.getEntitiesWithinAABB(getClass(), boundingBox.addCoord(f, f, f));
      for (int k = 0; k < list2.size(); k++) {
        EntityAnimal entityanimal1 = (EntityAnimal) list2.get(k);
        if (entityanimal1 != this && entityanimal1.func_40146_g() < 0) {
          return entityanimal1;
        }
      }
    }
    return null;
  }
  public void onUpdate() {
    if (j < 1023) {
      j++;
    } else if (i < 127) {
      i++;
    } else {
      int k = 0;
      List list =
          worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(16D, 16D, 16D));
      for (int l = 0; l < list.size(); l++) {
        Entity entity = (Entity) list.get(l);
        if (entity instanceof EntityBunny) {
          k++;
        }
      }

      if (k > 12) {
        proceed();
        return;
      }
      List list1 =
          worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 1.0D, 1.0D));
      boolean flag = false;
      for (int i1 = 0; i1 < list.size(); i1++) {
        Entity entity1 = (Entity) list1.get(i1);
        if (!(entity1 instanceof EntityBunny) || entity1 == this) {
          continue;
        }
        EntityBunny entitybunny = (EntityBunny) entity1;
        if (entitybunny.worldObj != null || entitybunny.j < 1023) {
          continue;
        }
        EntityBunny entitybunny1 = new EntityBunny(worldObj);
        entitybunny1.setPosition(posX, posY, posZ);
        worldObj.entityJoinedWorld(entitybunny1);
        worldObj.playSoundAtEntity(
            this, "mob.chickenplop", 1.0F, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
        proceed();
        entitybunny.proceed();
        flag = true;
        break;
      }

      if (!flag) {
        k = rand.nextInt(16);
      }
    }
    super.onUpdate();
  }
 public void onLivingUpdate() {
   super.onLivingUpdate();
   e = b;
   d = c;
   c = (float) ((double) c + (double) (onGround ? -1 : 4) * 0.29999999999999999D);
   if (c < 0.0F) {
     c = 0.0F;
   }
   if (c > 1.0F) {
     c = 1.0F;
   }
   if (!onGround && f < 1.0F) {
     f = 1.0F;
   }
   f = (float) ((double) f * 0.90000000000000002D);
   b += f * 2.0F;
 }
Ejemplo n.º 19
0
 public void setDead() {
   for (int i = 0; i < children.size(); i++) {
     children.get(i).parent = null;
   }
   super.setDead();
 }
Ejemplo n.º 20
0
 protected void entityInit() {
   super.entityInit();
   this.dataWatcher.addObject(16, new Byte((byte) 0));
 }
Ejemplo n.º 21
0
 protected void updateAITasks() {
   this.sheepTimer = this.aiEatGrass.getEatGrassTick();
   super.updateAITasks();
 }
Ejemplo n.º 22
0
 /** (abstract) Protected helper method to read subclass entity data from NBT. */
 public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
   super.readEntityFromNBT(par1NBTTagCompound);
   this.setSheared(par1NBTTagCompound.getBoolean("Sheared"));
   this.setFleeceColor(par1NBTTagCompound.getByte("Color"));
 }
Ejemplo n.º 23
0
 /** (abstract) Protected helper method to write subclass entity data to NBT. */
 public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
   super.writeEntityToNBT(par1NBTTagCompound);
   par1NBTTagCompound.setBoolean("Sheared", this.getSheared());
   par1NBTTagCompound.setByte("Color", (byte) this.getFleeceColor());
 }
 public void knockBack(Entity entity, int k, double d2, double d3) {
   super.knockBack(entity, k, d2, d3);
 }
 public void setEntityDead() {
   counterEntity--;
   super.setEntityDead();
 }
Ejemplo n.º 26
0
 public void applyEntityCollision(Entity par1Entity) {
   super.applyEntityCollision(par1Entity);
   if (par1Entity instanceof EntityItem) {
     boolean y = wantsItem(((EntityItem) par1Entity).item);
   }
 }
 public void writeEntityToNBT(NBTTagCompound nbttagcompound) {
   super.writeEntityToNBT(nbttagcompound);
   nbttagcompound.setInteger("CounterEntity", counterEntity);
 }
 public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
   super.readEntityFromNBT(nbttagcompound);
   counterEntity = nbttagcompound.getInteger("CounterEntity");
 }
Ejemplo n.º 29
0
  public void onLivingUpdate() {
    if (hunger > 168000) {
      hunger = 168000;
    }
    if (hunger > 0) {
      hunger--;
    }
    /** This Cancels out the growingAge from EntityAgeable */
    int var1 = this.getGrowingAge();
    super.onLivingUpdate();
    this.setGrowingAge(var1);

    if (panic > 0) {
      panic--;
    }
    long i = TFCSeasons.getTotalTicks() - adultTime;

    if (i < 0) {
      i++;
      setGrowingAge((int) i);
    } else if (i > 0) {
      i--;
      setGrowingAge((int) i);
    }

    /*if(pregnant){
    	if(TFCSeasons.getTotalTicks() >= conception + pregnancyTime*TFCSettings.dayLength){
    		EntityAnimalTFC baby = new EntityAnimalTFC(worldObj, this,mateSizeMod);
    		giveBirth(baby);
    		pregnant = false;
    	}
    }*/

    if (this.getGrowingAge() != 0) {
      this.inLove = 0;
    }

    if (this.inLove > 0) {
      --this.inLove;
      String heart = "heart";

      if (this.inLove % 10 == 0) {
        double var2 = this.rand.nextGaussian() * 0.02D;
        double var4 = this.rand.nextGaussian() * 0.02D;
        double var6 = this.rand.nextGaussian() * 0.02D;
        this.worldObj.spawnParticle(
            heart,
            this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width,
            this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height),
            this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width,
            var2,
            var4,
            var6);
      }
    } else {
      this.breeding = 0;
    }
    if (pickUp > 0) {
      pickUp--;
    }
    if (hunger > 144000 && rand.nextInt(100) == 0 && health < getMaxHealth()) {
      health++;
    }
    for (EntityItem ei : this.capturedDrops) {
      ItemStack item = ei.item;
      if (item != null) {
        if (hunger < 144000 && fooditems.contains(item.itemID)) {
          renderBrokenItemStack(item);
          item = null;
          hunger += 24000;
          worldObj.playSoundAtEntity(
              this,
              "random.eat",
              0.5F + 0.5F * (float) rand.nextInt(2),
              (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
        }
      }
    }
    if (getHealth() > 0) {
      List list =
          worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D));

      if (list != null) {
        for (int j = 0; j < list.size(); j++) {
          Entity entity = (Entity) list.get(j);

          if (!entity.isDead) {
            // entity.onCollideWithAnimal (this);
          }
        }
      }
    }

    if (TFCSeasons.getTotalTicks() > (birthTime + adultAge * TFCSettings.dayLength)) {
      setGrowingAge(0);
    } else if (isChild()) {
      setGrowingAge(
          (int) (TFCSeasons.getTotalTicks() - (birthTime + adultAge * TFCSettings.dayLength)));
    }
  }
Ejemplo n.º 30
0
 /** (abstract) Protected helper method to read subclass entity data from NBT. */
 public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
   super.readEntityFromNBT(par1NBTTagCompound);
   this.setSaddled(par1NBTTagCompound.getBoolean("Saddle"));
 }