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 ItemStack getEggs() { if (TFC_Time.getTotalTicks() >= this.nextEgg) { this.nextEgg = TFC_Time.getTotalTicks() + EggTime; return new ItemStack(TFCItems.Egg, 1); } return null; }
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); } }
@Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { if (type.contains(TickType.PLAYER)) { EntityPlayer player = (EntityPlayer) tickData[0]; World world = player.worldObj; // Allow the client to increment time TFC_Time.UpdateTime(world); } }
public static ItemStack createTag(ItemStack is, float weight) { NBTTagCompound nbt = is.getTagCompound(); if (nbt == null) nbt = new NBTTagCompound(); nbt.setFloat("foodWeight", weight); nbt.setFloat("foodDecay", 0); nbt.setInteger("decayTimer", (int) TFC_Time.getTotalHours() + 1); is.setTagCompound(nbt); return is; }
public EntityChickenTFC(World world, IAnimal mother, ArrayList<Float> data) { this(world); float father_size = data.get(0); this.posX = ((EntityLivingBase) mother).posX; this.posY = ((EntityLivingBase) mother).posY; this.posZ = ((EntityLivingBase) mother).posZ; size_mod = (((rand.nextInt(degreeOfDiversion + 1) * 10 * (rand.nextBoolean() ? 1 : -1)) / 100f) + 1F) * (1.0F - 0.1F * sex) * (float) Math.sqrt((mother.getSize() + father_size) / 1.9F); size_mod = Math.min(Math.max(size_mod, 0.7F), 1.3f); // We hijack the growingAge to hold the day of birth rather // than number of ticks to next growth event. // this.setAge((int) TFC_Time.getTotalDays()); }
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(); } }
public EntityChickenTFC( World world, double posX, double posY, double posZ, NBTTagCompound genes) { this(world); this.posX = posX; this.posY = posY; this.posZ = posZ; float m_size = genes.getFloat("m_size"); float f_size = genes.getFloat("f_size"); size_mod = (((rand.nextInt(degreeOfDiversion + 1) * (rand.nextBoolean() ? 1 : -1)) / 10f) + 1F) * (1.0F - 0.1F * sex) * (float) Math.sqrt((m_size + f_size) / 1.9F); // size_mod = Math.min(Math.max(size_mod, 0.7F),1.3f); // We hijack the growingAge to hold the day of birth rather // than number of ticks to next growth event. // this.setAge((int) TFC_Time.getTotalDays()); }
@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()); } } }
@Override public boolean isAdult() { return getBirthDay() + getNumberOfDaysToAdult() <= TFC_Time.getTotalDays(); }
@Override public void drawScreen(int par1, int par2, float par3) { this.mc.func_110434_K().func_110577_a(texture); int var4 = this.guiLeft; int var5 = this.guiTop; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int l = (width - xSize) / 2; int i1 = (height - ySize) / 2; drawTexturedModalRect(l, i1, 0, 0, xSize, ySize); drawCenteredString( fontRenderer, StringUtil.localize("gui.Calendar.Calendar"), l + 87, i1 + 16, 0xFFFFFF); drawCenteredString( fontRenderer, StringUtil.localize("gui.Calendar.Season") + " : " + TFC_Time.seasons[TFC_Time.getMonth()], l + 87, i1 + 26, 0x000000); drawCenteredString( fontRenderer, StringUtil.localize("gui.Calendar.Day") + " : " + TFC_Time.Days[TFC_Time.getDayOfWeek()], l + 87, i1 + 36, 0x000000); int dom = TFC_Time.getDayOfMonth(); int month = TFC_Time.currentMonth; if (dom == 7 && month == 4) { drawCenteredString( fontRenderer, StringUtil.localize("gui.Calendar.DateBioxx") + ", " + (1000 + TFC_Time.getYear()), l + 87, i1 + 46, 0x000000); } else { drawCenteredString( fontRenderer, StringUtil.localize("gui.Calendar.Date") + " : " + dom + " " + TFC_Time.months[month] + ", " + (1000 + TFC_Time.getYear()), l + 87, i1 + 46, 0x000000); } float temp = Math.round( (TFC_Climate.getHeightAdjustedTemp( (int) player.posX, (int) player.posY, (int) player.posZ))); // drawCenteredString(fontRenderer,"Temperature : " + (int)temp + "C", l + 87, i1+56, 0x000000); // drawCenteredString(fontRenderer,"Month : " + , l + 87, i1+36, 0x000000); long h = TFC_Time.getHour(); String hour = ""; if (h == 0) { hour = StringUtil.localize("gui.Calendar.WitchHour"); } else { hour += h; } drawCenteredString( fontRenderer, StringUtil.localize("gui.Calendar.Hour") + " : " + hour, l + 87, i1 + 56, 0x000000); // drawCenteredString(fontRenderer,"EVT : " + // ((TFCWorldChunkManager)world.provider.worldChunkMgr).getEVTLayerAt((int) player.posX, (int) // player.posZ).floatdata1, l + 87, i1+76, 0x000000); // int rain = (int) TFC_Climate.getRainfall((int) player.posX,(int) player.posY, (int) // player.posZ); // drawCenteredString(fontRenderer,"Rain : " + rain, l + 87, i1+86, 0x000000); for (int var6 = 0; var6 < this.buttonList.size(); ++var6) { GuiButton var7 = (GuiButton) this.buttonList.get(var6); var7.drawButton(this.mc, par1, par2); } }
@Override public void updateTick(World world, int i, int j, int k, Random rand) { FloraManager manager = FloraManager.getInstance(); FloraIndex fi = manager.findMatchingIndex(this.getType(world.getBlockMetadata(i, j, k))); float temp = TFC_Climate.getHeightAdjustedTemp(i, j, k); if (!world.isRemote && world.getBlockTileEntity(i, j, k) != null && TFC_Time.currentMonth < 6 && fi != null && temp >= fi.minTemp && temp < fi.maxTemp) { TileEntityFruitTreeWood te = (TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k); int t = 1; if (TFC_Time.currentMonth < 3) t = 2; int leafGrowthRate = 20; int trunkGrowTime = 30; int branchGrowTime = 20; // grow upward if (te.birthTimeWood + trunkGrowTime < TFC_Time.totalDays() && te.height < 3 && te.isTrunk && rand.nextInt(16 / t) == 0 && (world.getBlockId(i, j + 1, k) == 0 || world.getBlockId(i, j + 1, k) == TFCBlocks.fruitTreeLeaves.blockID)) { world.setBlockAndMetadata(i, j + 1, k, this.blockID, world.getBlockMetadata(i, j, k)); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j + 1, k)).setTrunk(true); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j + 1, k)).setHeight(te.height + 1); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j + 1, k)).setBirth(); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k)).setBirthWood(trunkGrowTime); } else if (te.birthTimeWood + branchGrowTime < TFC_Time.totalDays() && te.height == 2 && te.isTrunk && rand.nextInt(16 / t) == 0 && world.getBlockId(i, j + 1, k) != blockID) { int r = rand.nextInt(4); if (r == 0 && world.getBlockId(i + 1, j, k) == 0 || world.getBlockId(i + 1, j, k) == TFCBlocks.fruitTreeLeaves.blockID) { world.setBlockAndMetadata(i + 1, j, k, this.blockID, world.getBlockMetadata(i, j, k)); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i + 1, j, k)).setTrunk(false); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i + 1, j, k)).setHeight(te.height); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i + 1, j, k)).setBirth(); } else if (r == 1 && world.getBlockId(i, j, k - 1) == 0 || world.getBlockId(i, j, k - 1) == TFCBlocks.fruitTreeLeaves.blockID) { world.setBlockAndMetadata(i, j, k - 1, this.blockID, world.getBlockMetadata(i, j, k)); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k - 1)).setTrunk(false); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k - 1)).setHeight(te.height); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k - 1)).setBirth(); } else if (r == 2 && world.getBlockId(i - 1, j, k) == 0 || world.getBlockId(i - 1, j, k) == TFCBlocks.fruitTreeLeaves.blockID) { world.setBlockAndMetadata(i - 1, j, k, this.blockID, world.getBlockMetadata(i, j, k)); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i - 1, j, k)).setTrunk(false); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i - 1, j, k)).setHeight(te.height); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i - 1, j, k)).setBirth(); } else if (r == 3 && world.getBlockId(i, j, k + 1) == 0 || world.getBlockId(i, j, k + 1) == TFCBlocks.fruitTreeLeaves.blockID) { world.setBlockAndMetadata(i, j, k + 1, this.blockID, world.getBlockMetadata(i, j, k)); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k + 1)).setTrunk(false); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k + 1)).setHeight(te.height); ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k + 1)).setBirth(); } ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k)).setBirthWood(branchGrowTime); } else if (te.birthTimeWood + 1 < TFC_Time.totalDays() && rand.nextInt(leafGrowthRate) == 0 && world.getBlockId(i, j + 2, k) != blockID) { if (world.getBlockId(i, j + 1, k) == 0 && world.getBlockId(i, j + 2, k) == 0 && BlockFruitLeaves.canStay( world, i, j + 1, k, TFCBlocks.fruitTreeLeaves.blockID)) // above { world.setBlockAndMetadata( i, j + 1, k, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k)); world.markBlockForUpdate(i, j + 1, k); } else if (world.getBlockId(i + 1, j, k) == 0 && world.getBlockId(i + 1, j + 1, k) == 0 && BlockFruitLeaves.canStay( world, i + 1, j, k, TFCBlocks.fruitTreeLeaves.blockID)) // +x { world.setBlockAndMetadata( i + 1, j, k, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k)); world.markBlockForUpdate(i + 1, j, k); } else if (world.getBlockId(i - 1, j, k) == 0 && world.getBlockId(i - 1, j + 1, k) == 0 && BlockFruitLeaves.canStay( world, i - 1, j, k, TFCBlocks.fruitTreeLeaves.blockID)) // -x { world.setBlockAndMetadata( i - 1, j, k, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k)); world.markBlockForUpdate(i - 1, j, k); } else if (world.getBlockId(i, j, k + 1) == 0 && world.getBlockId(i, j + 1, k + 1) == 0 && BlockFruitLeaves.canStay( world, i, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID)) // +z { world.setBlockAndMetadata( i, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k)); world.markBlockForUpdate(i, j, k + 1); } else if (world.getBlockId(i, j, k - 1) == 0 && world.getBlockId(i, j + 1, k - 1) == 0 && BlockFruitLeaves.canStay( world, i, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID)) // -z { world.setBlockAndMetadata( i, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k)); world.markBlockForUpdate(i, j, k - 1); } else if (world.getBlockId(i + 1, j, k - 1) == 0 && world.getBlockId(i + 1, j + 1, k - 1) == 0 && BlockFruitLeaves.canStay( world, i + 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID)) // +x/-z { world.setBlockAndMetadata( i + 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k)); world.markBlockForUpdate(i + 1, j, k - 1); } else if (world.getBlockId(i + 1, j, k + 1) == 0 && world.getBlockId(i + 1, j + 1, k + 1) == 0 && BlockFruitLeaves.canStay( world, i + 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID)) // +x/+z { world.setBlockAndMetadata( i + 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k)); world.markBlockForUpdate(i + 1, j, k + 1); } else if (world.getBlockId(i - 1, j, k - 1) == 0 && world.getBlockId(i - 1, j + 1, k - 1) == 0 && BlockFruitLeaves.canStay( world, i - 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID)) // -x/-z { world.setBlockAndMetadata( i - 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k)); world.markBlockForUpdate(i - 1, j, k - 1); } else if (world.getBlockId(i - 1, j, k + 1) == 0 && world.getBlockId(i - 1, j + 1, k + 1) == 0 && BlockFruitLeaves.canStay( world, i - 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID)) // -x/+z { world.setBlockAndMetadata( i - 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k)); world.markBlockForUpdate(i - 1, j, k + 1); } } } }