Add a registration system for spreadable block compatibility.
This PR adds a registration system for spreadable blocks (blocks which extend SpreadableBlock). Each "type" of spreadable block has its own registry instance, which maps a bare block (f.e. Dirt) to a spreadable block (f.e. Grass or Mycelium). Two instances are provided for mods extending vanilla grass and mycelium. Additional registries can be requested for new modded spreadable types. I believe this is the simplest implementation appropriate for FAPI which implements enough features to be useful and is minimally intrusive. For example, this provides enough functionality I expect to be able to use it in Terraform API.
Goals:
- Vanilla grass can spread to modded dirt and create the correct modded grass.
- Modded grass can spread to vanilla dirt or other modded dirt and create the correct vanilla or modded grass.
- The same goes for mycelium.
- Additional registries can be easily created for new blocks which extend SpreadableBlock.
This PR does not address decay of spreadable blocks, because that can be easily handled by mods via mixin.
This PR also does not address allowing mods to change the conditions for spread (such as minimum and maximum light levels), although I could imagine this registry optionally storing a reference to an alternative canSpread method to be used in lieu of vanilla's call to the static method in SpreadableBlock (if only they used an instance method instead ... sigh).
I have added tests to the test mod and tested using runTestmodClient, and also by modifying Terrestria to use the API in production.
Going to keep this one in last call for a little longer, I think there are still some design questions to be clarified.
Going to keep this one in last call for a little longer, I think there are still some design questions to be clarified.
Yes, I am still not quite to a good point to pick this up again (and as I mentioned, it could probably be improved now that MixinExtras is available, anyway).
Yes, I am still not quite to a good point to pick this up again
No worries at all, Im quite happy to get this to the finish line myself, its 99% of the way there.