-
Notifications
You must be signed in to change notification settings - Fork 74
InvMenu v4.3 Changelog and Migration Notes
Muqsit Rayyan edited this page Jun 19, 2022
·
5 revisions
InvMenu v4.3 focuses on refactoring of invmenu\metadata
to make registering custom InvMenu types simpler, and gaining more flexibility when dealing with sending graphic portion of an InvMenu type. If you are not registering custom InvMenu types, the changes made in this version will not affect you.
-
InvMenuHandler
is no longer aMenuMetadata
registry.
To register custom InvMenu types, useInvMenuHandler::getTypeRegistry()->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
. Constructing these classes may be quite complicated, however each of the three implementations ofInvMenuType
s can be instantiated using built-in builder patterns.
-
InvMenu::getType()
now returnsInvMenuType
rather thanMenuMetadata
-
InvMenu::getInventory()
now returnsInventory
rather thanInvMenuInventory
To register a custom InvMenu type, use InvMenuHandler::getTypeRegistry()->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::getTypeRegistry()->register(self::TYPE_DISPENSER, InvMenuTypeBuilders::BLOCK_ACTOR_FIXED()
->setBlock(BlockFactory::getInstance()->get(BlockLegacyIds::DISPENSER, 0))
->setBlockActorId("Dispenser")
->setSize(9)
->setNetworkWindowType(WindowTypes::DISPENSER)
->build());