CivClassic / RealisticBiomes

Minecraft plugin that limits plant growth and animal reproduction to their naturally occuring biomes, or reasonable ones for plants that do not occur naturally. Built for Paper 1.16.5
MIT License
1 stars 12 forks source link

Fixed big trees not growing #20

Closed Falvyu closed 4 years ago

Falvyu commented 4 years ago

This fixes #18

The issue was that the block.getLocation().getWorld().generateTree(block.getLocation(), type); was returning false when the saplings were still present. This isn't an issue for normal 1x1 trees because the sapling is removed before the call. However, removing 1 sapling isn't enough for 2x2 trees as they requires 4 saplings.

The solution here is to find the 2x2 area with findNWSapling(Block block, Material mat) and then to set all 4 saplings to air.

This does cause a minor issue as PlantManager contains what I assume is a set of Block which don't automatically update. As a result RB would later try to grow some of the removed saplings (unsuccessfully because generateTree() refused) but would still remove the log. The solution here is fairly dirty: BlockData currentBlockData = block.getLocation().getBlock().getBlockData(); is called to fetch the most recent block state from memory.

PS: I just realized that could abuse the aforementioned block fetch:

  1. Plant 1 sapling
  2. Complete the 2x2 area with other sapling later.
  3. The first sapling grows and remove the others. The other plants are still "ticking" even though their saplings are gone.
  4. Cut the tree before that happens and replace the saplings.
  5. Another big tree will grow when the Plants placed in (2) will be "fully grown" prematurely.

I'm going to fix that issue by making calls PlantManager.deletePlant() for each sapling when clearing them.

Maxopoly commented 4 years ago

Nice work, will merge once you add the fix you mentioned.

Maxopoly commented 4 years ago

Thanks for contributing