This pull request aims to solve two big problems with the CustomiesBlockFactory->registerBlock() API:
The current method is very limiting and does not work for every type of block due to different constructor signatures. For example slabs require a BlockIdentifierFlattened whereas we only accept a BlockIdentifier, meaning the user needs to create a new class that inherits the same behaviour to use within Customies.
The way we currently register blocks on all threads is by serializing the Block objects and using the same registering method. This causes issues when blocks inherit properties that are not serialiable, crashing the server as a result. Using slabs as an example again, their SlabType is an enum which implements the NotSerializable trait.
The solution to both of these problems is instead of accepting a class name along with other information such as BlockBreakInfo, we instead accept a single Closure which returns an instance of the Block. This allows for blocks to be constructed however they are needed, and also removes the requirement for serializing the Block objects to register them on other threads.
This pull request aims to solve two big problems with the
CustomiesBlockFactory->registerBlock()
API:BlockIdentifierFlattened
whereas we only accept aBlockIdentifier
, meaning the user needs to create a new class that inherits the same behaviour to use within Customies.SlabType
is an enum which implements theNotSerializable
trait.The solution to both of these problems is instead of accepting a class name along with other information such as
BlockBreakInfo
, we instead accept a single Closure which returns an instance of the Block. This allows for blocks to be constructed however they are needed, and also removes the requirement for serializing the Block objects to register them on other threads.