@Override public boolean canBlockFreeze(int x, int y, int z, boolean byWater) { if (TFC_Climate.getHeightAdjustedTemp(x, y, z) <= 0 && (worldObj.getBlockMaterial(x, y, z) == Material.water || worldObj.getBlockMaterial(x, y, z) == Material.ice)) return true; return false; }
@Override public void updateEntity() { if (!worldObj.isRemote) { inputTick++; outputTick++; tempTick++; /*Heat the crucible based on the Forge beneath it*/ if (worldObj.getBlockId(xCoord, yCoord - 1, zCoord) == TFCBlocks.Forge.blockID) { TileEntityForge te = (TileEntityForge) worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord); if (te.fireTemperature > temperature) { temperature++; } } if (tempTick > 22) { tempTick = 0; if (temperature > TFC_Climate.getHeightAdjustedTemp(xCoord, yCoord, zCoord)) { temperature--; } } ItemStack stackToSmelt = storage[0]; if (stackToSmelt != null) { Item itemToSmelt = stackToSmelt.getItem(); if (itemToSmelt instanceof ItemMeltedMetal && TFC_ItemHeat.getIsLiquid(storage[0])) { if (inputTick > 5) { if (currentAlloy != null && currentAlloy.outputType != null && itemToSmelt.itemID == currentAlloy.outputType.MeltedItemID) { this.addMetal(MetalRegistry.instance.getMetalFromItem(itemToSmelt), (short) 1); if (stackToSmelt.getItemDamage() + 1 >= storage[0].getMaxDamage()) { storage[0] = new ItemStack(TFCItems.CeramicMold, 1, 1); } else { stackToSmelt.setItemDamage(stackToSmelt.getItemDamage() + 1); } } else { this.addMetal(MetalRegistry.instance.getMetalFromItem(itemToSmelt), (short) 1); if (stackToSmelt.getItemDamage() + 1 >= stackToSmelt.getMaxDamage()) { storage[0] = new ItemStack(TFCItems.CeramicMold, 1, 1); } else { stackToSmelt.setItemDamage(stackToSmelt.getItemDamage() + 1); } } inputTick = 0; updateGui((byte) 0); } } else if (itemToSmelt instanceof ISmeltable && ((ISmeltable) itemToSmelt).isSmeltable(stackToSmelt) && !TFC_Core.isOreIron(stackToSmelt) && temperature >= TFC_ItemHeat.getMeltingPoint(stackToSmelt)) { Metal mType = ((ISmeltable) itemToSmelt).GetMetalType(stackToSmelt); if (addMetal(mType, ((ISmeltable) itemToSmelt).GetMetalReturnAmount(stackToSmelt))) { temperature *= 0.9f; if (stackToSmelt.stackSize <= 1) { storage[0] = null; } updateGui((byte) 0); } } } // Metal Output handling if (currentAlloy != null && storage[1] != null && currentAlloy.outputType != null && outputTick >= 3 && temperature >= TFC_ItemHeat.getMeltingPoint(currentAlloy.outputType)) { if (storage[1].itemID == TFCItems.CeramicMold.itemID) { storage[1] = new ItemStack(Item.itemsList[currentAlloy.outputType.MeltedItemID], 1, 99); TFC_ItemHeat.SetTemperature(storage[1], temperature); // currentAlloy.outputAmount--; drainOutput(1.0f); updateGui((byte) 1); } else if (storage[1].itemID == currentAlloy.outputType.MeltedItemID && storage[1].getItemDamage() > 0) { storage[1].setItemDamage(storage[1].getItemDamage() - 1); float inTemp = TFC_ItemHeat.GetTemperature(storage[1]); float temp = (temperature - inTemp) / 2; TFC_ItemHeat.SetTemperature(storage[1], inTemp + temp); // System.out.println(temperature +", "+inTemp+", "+temp); // currentAlloy.outputAmount--; drainOutput(1.0f); storage[1].stackSize = 1; updateGui((byte) 1); } outputTick = 0; } if (currentAlloy != null && currentAlloy.outputAmount <= 0) { metals = new HashMap(); updateCurrentAlloy(); this.updateGui((byte) 2); currentAlloy = null; } if (storage[1] != null && storage[1].stackSize <= 0) { storage[1].stackSize = 1; } if (inputTick > 5) { inputTick = 0; } if (outputTick >= 3) { outputTick = 0; } } }
@Override public boolean canSnowAt(int x, int y, int z) { if (TFC_Climate.getHeightAdjustedTemp(x, y, z) <= 0) return true; return false; }
@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 generate( Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { chunkX *= 16; chunkZ *= 16; int xCoord; int yCoord; int zCoord; int grassPerChunk = 0; int flowersPerChunk = 0; int mushroomsPerChunk = 0; DataLayer evt = ((TFCWorldChunkManager) world.provider.worldChunkMgr).getEVTLayerAt(chunkX, chunkZ); DataLayer rainfall = ((TFCWorldChunkManager) world.provider.worldChunkMgr).getRainfallLayerAt(chunkX, chunkZ); float bioTemperature; if (rainfall.floatdata1 >= 62.5f) {} if (rainfall.floatdata1 >= 125) { grassPerChunk += 12; flowersPerChunk += 1; mushroomsPerChunk += 1; } if (rainfall.floatdata1 >= 250) { grassPerChunk += 18; flowersPerChunk += 1; mushroomsPerChunk += 1; } if (rainfall.floatdata1 >= 500) { grassPerChunk += 24; flowersPerChunk += 1; mushroomsPerChunk += 1; } if (rainfall.floatdata1 >= 1000) { mushroomsPerChunk += 1; } if (rainfall.floatdata1 >= 2000) { mushroomsPerChunk += 1; } for (int i = 0; i < flowersPerChunk; ++i) { xCoord = chunkX + random.nextInt(16) + 8; zCoord = chunkZ + random.nextInt(16) + 8; yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord); bioTemperature = TFC_Climate.getBioTemperatureHeight(xCoord, yCoord, zCoord); if (bioTemperature > 1.5) { plantYellowGen.generate(world, random, xCoord, yCoord, zCoord); if (random.nextInt(4) == 0) { xCoord = chunkX + random.nextInt(16) + 8; zCoord = chunkZ + random.nextInt(16) + 8; yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord); bioTemperature = TFC_Climate.getBioTemperatureHeight(xCoord, yCoord, zCoord); if (bioTemperature > 1.5) { plantRedGen.generate(world, random, xCoord, yCoord, zCoord); } } } } for (int i = 0; i < grassPerChunk; ++i) { xCoord = chunkX + random.nextInt(16) + 8; zCoord = chunkZ + random.nextInt(16) + 8; yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord); bioTemperature = TFC_Climate.getBioTemperatureHeight(xCoord, yCoord, zCoord); if (bioTemperature >= 1.5) { // WorldGenerator var6 = new WorldGenCustomTallGrass(Block.tallGrass.blockID, 1); // var6.generate(world, random, xCoord, yCoord, zCoord); if (world.isAirBlock(xCoord, yCoord, zCoord) && ((BlockCustomTallGrass) Block.blocksList[Block.tallGrass.blockID]) .canBlockStay(world, xCoord, yCoord, zCoord)) { world.setBlock(xCoord, yCoord, zCoord, Block.tallGrass.blockID, 1, 0x2); } } } for (int i = 0; i < mushroomsPerChunk; ++i) { if (random.nextInt(4) == 0) { xCoord = chunkX + random.nextInt(16) + 8; zCoord = chunkZ + random.nextInt(16) + 8; yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord); mushroomBrownGen.generate(world, random, xCoord, yCoord, zCoord); } if (random.nextInt(8) == 0) { xCoord = chunkX + random.nextInt(16) + 8; zCoord = chunkZ + random.nextInt(16) + 8; yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord); mushroomRedGen.generate(world, random, xCoord, yCoord, zCoord); } } if (random.nextInt(70) == 0 && rainfall.floatdata1 > 500) { xCoord = chunkX + random.nextInt(16) + 8; zCoord = chunkZ + random.nextInt(16) + 8; yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord); switch (random.nextInt(9)) { default: { if (world.getBlockId(xCoord, yCoord, zCoord) == 0 && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) { appleTree.generate(world, random, xCoord, yCoord, zCoord); } break; } case 1: { if (world.getBlockId(xCoord, yCoord, zCoord) == 0 && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) { bananaTree.generate(world, random, xCoord, yCoord, zCoord); } break; } case 2: { if (world.getBlockId(xCoord, yCoord, zCoord) == 0 && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) { orangeTree.generate(world, random, xCoord, yCoord, zCoord); } break; } case 3: { if (world.getBlockId(xCoord, yCoord, zCoord) == 0 && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) { grappleTree.generate(world, random, xCoord, yCoord, zCoord); } break; } case 4: { if (world.getBlockId(xCoord, yCoord, zCoord) == 0 && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) { lemonTree.generate(world, random, xCoord, yCoord, zCoord); } break; } case 5: { if (world.getBlockId(xCoord, yCoord, zCoord) == 0 && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) { oliveTree.generate(world, random, xCoord, yCoord, zCoord); } break; } case 6: { if (world.getBlockId(xCoord, yCoord, zCoord) == 0 && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) { cherryTree.generate(world, random, xCoord, yCoord, zCoord); } break; } case 7: { if (world.getBlockId(xCoord, yCoord, zCoord) == 0 && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) { peachTree.generate(world, random, xCoord, yCoord, zCoord); } break; } case 8: { if (world.getBlockId(xCoord, yCoord, zCoord) == 0 && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) { plumTree.generate(world, random, xCoord, yCoord, zCoord); } break; } // case 9: // { // if(world.getBlockId(var2, var3, var4) == 0 && // (world.getBlockId(var2, var3-1, var4) == mod_TFC_Core.terraGrass.blockID || // world.getBlockId(var2, var3-1, var4) == mod_TFC_Core.terraGrass2.blockID)) // cacaoTree.generate(world, rand, var2, var3, var4); // break; // } } } }
@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); } } } }