-
Notifications
You must be signed in to change notification settings - Fork 79
InvMenu v4.3 Changelog and Migration Notes
Muqsit Rayyan edited this page Jun 9, 2021
·
5 revisions
InvMenu v4.3 focuses on refactoring invmenu\metadata
for the purpose of ease in registering custom InvMenu types and gaining more flexibility. The changes made in this version should not affect you if you are not registering custom InvMenu types.
-
InvMenuHandler
is no longer aMenuMetadata
registry.
To register custom InvMenu types, useInvMenuHandler::getRegistry()->register()
instead. -
MenuMetadata
has been replaced withInvMenuType
Unlike whatMenuMetadata
was,InvMenuType
is block-agnostic as not all inventories may be backed by a block.
By default, InvMenu comes with three implementations ofInvMenuType
—BlockFixedInvMenuType
,BlockActorFixedInvMenuType
andDoublePairableBlockActorFixedInvMenuType
. As construction of these classes could seem complicated at first, builder patterns have been added for each implementation ofInvMenuType
.
-
InvMenu::getType()
now returnsInvMenuType
rather thanMenuMetadata
-
InvMenu::getInventory()
now returnsInventory
rather thanInvMenuInventory
To register a custom InvMenu type, use InvMenuHandler::getRegistry()->register()
instead.
While you can still create custom implementations of InvMenuType
, the built-in InvMenuType
s can be instantiated using builder patterns specified in InvMenuTypeBuilders
.
// InvMenu <= v4.2.x
$type = new SingleBlockMenuMetadata(
self::TYPE_DISPENSER, // identifier
9, // number of slots
WindowTypes::DISPENSER, // mcpe window type id
BlockFactory::get(Block::DISPENSER), // Block
"Dispenser" // block entity identifier
);
InvMenuHandler::registerMenuType($type);
// InvMenu v4.3.0
InvMenuHandler::getRegistry()->register(self::TYPE_DISPENSER, InvMenuTypeBuilders::BLOCK_FIXED()
->setBlock(BlockFactory::get(Block::DISPENSER))
->setBlockActorId("Dispenser")
->setSize(9)
->setNetworkWindowType(WindowTypes::DISPENSER)
->build());