mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Inventory: Removed need for Inventory to have an InventoryHolder
Inventory holders are now freed from BaseInventory. They are now declared by subclasses by convention, but are not required in most cases. Ideally, this would be followed by the removal of the need for inventories to know their holders at all. They should just be simple containers of items. This fixes #1560 by removing FakeBlockMenu.
This commit is contained in:
@ -30,6 +30,14 @@ use pocketmine\network\mcpe\protocol\ContainerOpenPacket;
|
||||
use pocketmine\Player;
|
||||
|
||||
abstract class ContainerInventory extends BaseInventory{
|
||||
/** @var Vector3 */
|
||||
protected $holder;
|
||||
|
||||
public function __construct(Vector3 $holder, array $items = [], int $size = null, string $title = null){
|
||||
$this->holder = $holder;
|
||||
parent::__construct($items, $size, $title);
|
||||
}
|
||||
|
||||
public function onOpen(Player $who) : void{
|
||||
parent::onOpen($who);
|
||||
$pk = new ContainerOpenPacket();
|
||||
@ -65,4 +73,11 @@ abstract class ContainerInventory extends BaseInventory{
|
||||
* @return int
|
||||
*/
|
||||
abstract public function getNetworkType() : int;
|
||||
|
||||
/**
|
||||
* @return Vector3
|
||||
*/
|
||||
public function getHolder(){
|
||||
return $this->holder;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user