- 
                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 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.
- 
InvMenuHandleris no longer aMenuMetadataregistry.
 To register custom InvMenu types, useInvMenuHandler::getTypeRegistry()->register()instead.
- 
MenuMetadatahas been replaced withInvMenuType
 Unlike whatMenuMetadatawas,InvMenuTypeis block-agnostic as not all inventories may be backed by a block.
 By default, InvMenu comes with three implementations ofInvMenuType—BlockFixedInvMenuType,BlockActorFixedInvMenuTypeandDoublePairableBlockActorFixedInvMenuType. Constructing these classes may be quite complicated, however each of the three implementations ofInvMenuTypes can be instantiated using built-in builder patterns.
- 
InvMenu::getType()now returnsInvMenuTyperather thanMenuMetadata
- 
InvMenu::getInventory()now returnsInventoryrather thanInvMenuInventory
To register a custom InvMenu type, use InvMenuHandler::getTypeRegistry()->register() instead.
While you can still create custom implementations of InvMenuType, the built-in InvMenuTypes 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());