public ItemStack getEggs() {
   if (TFC_Time.getTotalTicks() >= this.nextEgg) {
     this.nextEgg = TFC_Time.getTotalTicks() + EggTime;
     return new ItemStack(TFCItems.Egg, 1);
   }
   return null;
 }
  public EntityChickenTFC(World par1World) {
    super(par1World);
    this.setSize(0.3F, 0.7F);
    this.timeUntilNextEgg = 9999; // Here we set the vanilla egg timer to 9999
    this.nextEgg = TFC_Time.getTotalTicks() + EggTime;
    hunger = 168000;
    mateSizeMod = 1f;
    sex = rand.nextInt(2);

    this.tasks.taskEntries.clear();
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIPanic(this, 1.4D));
    this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
    this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    this.tasks.addTask(7, new EntityAILookIdle(this));
    this.tasks.addTask(6, this.aiEatGrass);
    addAI();

    size_mod =
        (((rand.nextInt((degreeOfDiversion + 1) * 10) * (rand.nextBoolean() ? 1 : -1)) / 100f) + 1F)
            * (1.0F - 0.1F * sex);

    //	We hijack the growingAge to hold the day of birth rather
    //	than number of ticks to next growth event. We want spawned
    //	animals to be adults, so we set their birthdays far enough back
    //	in time such that they reach adulthood now.
    //
    this.setAge((int) TFC_Time.getTotalDays() - getNumberOfDaysToAdult());
    // For Testing Only(makes spawned animals into babies)
    // this.setGrowingAge((int) TFC_Time.getTotalDays());
  }
 public void roosterCrow() {
   if ((TFC_Time.getTotalTicks() - 15) % TFC_Time.dayLength == 0
       && getGender() == GenderEnum.MALE
       && isAdult()) {
     this.playSound(TFC_Sounds.ROOSTERCROW, 10, rand.nextFloat() + 0.5F);
   }
 }
Beispiel #4
0
  public void StartPitFire() {
    int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
    if (meta == 15) {
      TileEntityLogPile telp =
          (TileEntityLogPile) worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
      logsForBurn = telp.getNumberOfLogs();
      telp.clearContents();
      worldObj.setBlock(xCoord, yCoord + 1, zCoord, Block.fire.blockID);

      int ratio = TFC_Settings.pitKilnBurnTime / 16;

      int burnLength =
          (int)
              (TFC_Time.hourLength
                  * (logsForBurn == 16 ? TFC_Settings.pitKilnBurnTime : ratio * logsForBurn));
      burnStart = TFC_Time.getTotalTicks();
    }
  }
Beispiel #5
0
  @Override
  public void updateEntity() {
    // If there are no logs for burning then we dont need to tick at all
    if (!worldObj.isRemote && logsForBurn > 0) {
      // Check for any Logs that may have been thrown in the fire and add them to the fuel supply
      List list =
          worldObj.getEntitiesWithinAABB(
              EntityItem.class,
              AxisAlignedBB.getBoundingBox(
                  xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1));
      if (list != null && !list.isEmpty()) {
        for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
          EntityItem entity = (EntityItem) iterator.next();
          if (entity.getEntityItem().itemID == TFCItems.Logs.itemID) {
            logsForBurn += entity.getEntityItem().stackSize;
          }
        }
      }

      int blockAboveID = worldObj.getBlockId(xCoord, yCoord + 1, zCoord);
      // Make sure to keep the fire going throughout the length of the burn
      if (blockAboveID != Block.fire.blockID
          && TFC_Time.getTotalTicks() - burnStart
              < TFC_Time.hourLength * TFC_Settings.pitKilnBurnTime) {
        if (blockAboveID == 0 || worldObj.getBlockMaterial(xCoord, yCoord + 1, zCoord).getCanBurn())
          worldObj.setBlock(xCoord, yCoord + 1, zCoord, Block.fire.blockID);
        else logsForBurn = 0;
      }

      // If the total time passes then we complete the burn and turn the clay into ceramic
      if (logsForBurn > 0
          && blockAboveID == Block.fire.blockID
          && TFC_Time.getTotalTicks()
              > burnStart + (TFC_Settings.pitKilnBurnTime * TFC_Time.hourLength)) {
        worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3);
        worldObj.setBlock(xCoord, yCoord + 1, zCoord, 0);
        if (inventory[0] != null) {
          inventory[0] =
              KilnCraftingManager.getInstance().findCompleteRecipe(new KilnRecipe(inventory[0], 0));
          if (inventory[0].getItem() instanceof ItemPotteryBase) {
            ((ItemPotteryBase) inventory[0].getItem())
                .onDoneCooking(worldObj, inventory[0], Alloy.EnumTier.TierI);
          }
        }
        if (inventory[1] != null) {
          inventory[1] =
              KilnCraftingManager.getInstance().findCompleteRecipe(new KilnRecipe(inventory[1], 0));
          if (inventory[1].getItem() instanceof ItemPotteryBase) {
            ((ItemPotteryBase) inventory[1].getItem())
                .onDoneCooking(worldObj, inventory[1], Alloy.EnumTier.TierI);
          }
        }
        if (inventory[2] != null) {
          inventory[2] =
              KilnCraftingManager.getInstance().findCompleteRecipe(new KilnRecipe(inventory[2], 0));
          if (inventory[2].getItem() instanceof ItemPotteryBase) {
            ((ItemPotteryBase) inventory[2].getItem())
                .onDoneCooking(worldObj, inventory[2], Alloy.EnumTier.TierI);
          }
        }
        if (inventory[3] != null) {
          inventory[3] =
              KilnCraftingManager.getInstance().findCompleteRecipe(new KilnRecipe(inventory[3], 0));
          if (inventory[3].getItem() instanceof ItemPotteryBase) {
            ((ItemPotteryBase) inventory[3].getItem())
                .onDoneCooking(worldObj, inventory[3], Alloy.EnumTier.TierI);
          }
        }

        logsForBurn = 0;

        broadcastPacketInRange(createUpdatePacket());
      }
    }
  }