Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for overworld mushroom trees in forester #9924

Merged
merged 2 commits into from
Apr 21, 2024

Conversation

uecasm
Copy link
Contributor

@uecasm uecasm commented Apr 18, 2024

Closes ldtteam/minecolonies-features#202
Closes discord request

Changes proposed in this pull request:

  • Adds the ability to cut and replant overworld mushroom trees to the Forester (since they could already handle nether fungi trees).
    • You can plant the overworld mushrooms on whatever block you like (that they'll grow on), but podzol is the most recommended. (Mycelium decays back to dirt, so is not sustainable; unlike nylium there's no magic restoration.)
    • As with any of the other tree types, you will need to plant and grow the first one yourself (unless there's a nearby mushroom biome to harvest); after that it should be self-sustaining unless they run out of saplings.
  • Adds the overworld and nether mushroom "saplings" to the settings list, so that cutting can be disabled if desired.
    • Known (pre-existing) issue: if any forester in the colony has never cut down a particular overworld tree before the sapling was disabled, then they will still cut at least one down if available; the setting is only respected for the second and subsequent tree of that type. This is due to threading limitations between the pathfinding system and the loot system. The nether trees are not affected by this limitation.
  • When the "break leaves" setting is enabled (or for overworld/nether mushroom trees, where it's forced regardless of the setting), the Forester will now break the leaves before breaking the logs, so the overall tree cutting occurs top-down.
  • Includes leaf blocks only one block above the sapling in the breakable leaves list, since red mushrooms can generate that low. (Jungle bushes can also generate that low, but only in worldgen and not as proper trees.)
  • The internal sapling lookup cache is now based purely on block type rather than block state -- the previous implementation could cause spurious cache misses for entirely unrelated properties (like "waterlogged", and various facing directions of the mushroom blocks). The state-based implementation predated the Great Flattening; there aren't any vanilla trees where different states of the same block drop different saplings, so this should not be needed any more.
    • For backwards compatibility, persistence of this cache is still state-based, but it will not preserve all historic states on upgrade.
  • Attempts to use tags for more things to theoretically support additional mushroom tree types from mods, but some MineColonies-specific compatibility datapacks will still be required.

[x] Yes I tested this before submitting it.
[ ] I also did a multiplayer test.

Review please (could port)

@MotionlessTrain
Copy link
Contributor

When the "break leaves" setting is enabled (or for overworld/nether mushroom trees, where it's forced regardless of the setting), the Forester will now break the leaves before breaking the logs, so the overall tree cutting occurs top-down.

Would this work correctly when the forester gets interrupted after the leaves have been removed? (E.g. by rain, night or a raid) As I thought they only recognise trees when there is a leaf block at the top (so the tree is not really tree like anymore when they are allowed to work again)

@uecasm
Copy link
Contributor Author

uecasm commented Apr 18, 2024

I've tested it across night and they will correctly resume the tree the next morning. I haven't tested the other cases but it shouldn't be any worse than before -- they would otherwise have had the same problem when there's only leaves and no logs.

@Raycoms Raycoms merged commit 3695b9f into version/main Apr 21, 2024
2 checks passed
@Raycoms Raycoms deleted the feature/mushroom-tree branch April 21, 2024 13:40
Raycoms added a commit that referenced this pull request Apr 21, 2024
Adds the ability to cut and replant overworld mushroom trees to the Forester (since they could already handle nether fungi trees).
You can plant the overworld mushrooms on whatever block you like (that they'll grow on), but podzol is the most recommended. (Mycelium decays back to dirt, so is not sustainable; unlike nylium there's no magic restoration.)
As with any of the other tree types, you will need to plant and grow the first one yourself (unless there's a nearby mushroom biome to harvest); after that it should be self-sustaining unless they run out of saplings.
Adds the overworld and nether mushroom "saplings" to the settings list, so that cutting can be disabled if desired.
Known (pre-existing) issue: if any forester in the colony has never cut down a particular overworld tree before the sapling was disabled, then they will still cut at least one down if available; the setting is only respected for the second and subsequent tree of that type. This is due to threading limitations between the pathfinding system and the loot system. The nether trees are not affected by this limitation.
When the "break leaves" setting is enabled (or for overworld/nether mushroom trees, where it's forced regardless of the setting), the Forester will now break the leaves before breaking the logs, so the overall tree cutting occurs top-down.
Includes leaf blocks only one block above the sapling in the breakable leaves list, since red mushrooms can generate that low. (Jungle bushes can also generate that low, but only in worldgen and not as proper trees.)
The internal sapling lookup cache is now based purely on block type rather than block state -- the previous implementation could cause spurious cache misses for entirely unrelated properties (like "waterlogged", and various facing directions of the mushroom blocks). The state-based implementation predated the Great Flattening; there aren't any vanilla trees where different states of the same block drop different saplings, so this should not be needed any more.
For backwards compatibility, persistence of this cache is still state-based, but it will not preserve all historic states on upgrade.
Attempts to use tags for more things to theoretically support additional mushroom tree types from mods, but some MineColonies-specific compatibility datapacks will still be required.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mushroom Farmer
4 participants