diff --git a/src/Common/com/bioxx/tfc/Blocks/Flora/BlockSapling.java b/src/Common/com/bioxx/tfc/Blocks/Flora/BlockSapling.java index 0a7946972..400222978 100644 --- a/src/Common/com/bioxx/tfc/Blocks/Flora/BlockSapling.java +++ b/src/Common/com/bioxx/tfc/Blocks/Flora/BlockSapling.java @@ -74,14 +74,23 @@ public void registerBlockIcons(IIconRegister registerer) } - public void growTree(World world, int i, int j, int k, Random rand) + public void growTree(World world, int i, int j, int k, Random rand, long timestamp) { - int l = world.getBlockMetadata(i, j, k); + int meta = world.getBlockMetadata(i, j, k); world.setBlockToAir(i, j, k); - Object obj = TFCBiome.getTreeGen(l, rand.nextBoolean()); + WorldGenerator worldGen = TFCBiome.getTreeGen(meta, rand.nextBoolean()); - if (obj!= null && !((WorldGenerator) obj).generate(world, rand, i, j, k)) - world.setBlock(i, j, k, this, l, 3); + if (worldGen != null && !worldGen.generate(world, rand, i, j, k)) + { + world.setBlock(i, j, k, this, meta, 3); + if (world.getTileEntity(i, j, k) instanceof TESapling) + { + TESapling te = (TESapling) world.getTileEntity(i, j, k); + te.growTime = timestamp; + te.enoughSpace = false; + te.markDirty(); + } + } } @Override @@ -123,19 +132,20 @@ else if(meta == 9 || meta == 14|| meta == 15) @Override public void updateTick(World world, int i, int j, int k, Random rand) { - if (world.isRemote) - return; - - super.updateTick(world, i, j, k, rand); - - if (world.getTileEntity(i, j, k) instanceof TESapling) + if (!world.isRemote) { - TESapling te = (TESapling) world.getTileEntity(i, j, k); + super.updateTick(world, i, j, k, rand); + + if (world.getTileEntity(i, j, k) instanceof TESapling) + { + long timestamp = ((TESapling) world.getTileEntity(i, j, k)).growTime; - if (world.getBlockLightValue(i, j + 1, k) >= 9 && te != null && TFC_Time.getTotalTicks() > te.growTime) - growTree(world, i, j, k, rand); + if (world.getBlockLightValue(i, j + 1, k) >= 9 && TFC_Time.getTotalTicks() > timestamp) + { + growTree(world, i, j, k, rand, timestamp); + } + } } - //this.checkChange(world, i, j, k); } /** diff --git a/src/Common/com/bioxx/tfc/TileEntities/TESapling.java b/src/Common/com/bioxx/tfc/TileEntities/TESapling.java index 286657481..924ae57ac 100644 --- a/src/Common/com/bioxx/tfc/TileEntities/TESapling.java +++ b/src/Common/com/bioxx/tfc/TileEntities/TESapling.java @@ -9,6 +9,7 @@ public class TESapling extends TileEntity { public long growTime; + public boolean enoughSpace = true; public TESapling() { @@ -21,17 +22,19 @@ public boolean canUpdate() } @Override - public void readFromNBT(NBTTagCompound nbttagcompound) + public void readFromNBT(NBTTagCompound nbt) { - super.readFromNBT(nbttagcompound); - growTime = nbttagcompound.getLong("growTime"); + super.readFromNBT(nbt); + growTime = nbt.getLong("growTime"); + enoughSpace = nbt.getBoolean("enoughSpace"); } @Override - public void writeToNBT(NBTTagCompound nbttagcompound) + public void writeToNBT(NBTTagCompound nbt) { - super.writeToNBT(nbttagcompound); - nbttagcompound.setLong("growTime", growTime); + super.writeToNBT(nbt); + nbt.setLong("growTime", growTime); + nbt.setBoolean("enoughSpace", enoughSpace); } @Override diff --git a/src/Common/com/bioxx/tfc/WAILA/WAILAData.java b/src/Common/com/bioxx/tfc/WAILA/WAILAData.java index ae040c39b..0ea47e7a6 100644 --- a/src/Common/com/bioxx/tfc/WAILA/WAILAData.java +++ b/src/Common/com/bioxx/tfc/WAILA/WAILAData.java @@ -1130,10 +1130,17 @@ else if (burnStart > 0) public List saplingBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { NBTTagCompound tag = accessor.getNBTData(); - Long growTime = tag.getLong("growTime"); + boolean enoughSpace = tag.getBoolean("enoughSpace"); + long growTime = tag.getLong("growTime"); int days = (int) ((growTime - TFC_Time.getTotalTicks()) / TFC_Time.DAY_LENGTH); if (days > 0) + { currenttip.add(days + " " + TFC_Core.translate("gui.daysRemaining")); + } + else if (!enoughSpace) + { + currenttip.add(TFC_Core.translate("gui.enoughSpace")); + } return currenttip; } diff --git a/src/Resources/assets/terrafirmacraft/lang/en_US.lang b/src/Resources/assets/terrafirmacraft/lang/en_US.lang index 4b715b2f8..6f33e0208 100644 --- a/src/Resources/assets/terrafirmacraft/lang/en_US.lang +++ b/src/Resources/assets/terrafirmacraft/lang/en_US.lang @@ -2598,6 +2598,7 @@ gui.gems=Gems gui.familiarized=Familiarized gui.familiarity=Familiarity gui.baby=Baby +gui.enoughSpace=Clear space for growth option.tfc.oreQuality=Show ore quality option.tfc.gender=Show animal gender option.tfc.familiarToday=Show animal familiarized