mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 19:24:12 +00:00
Fixed crafting
This commit is contained in:
@ -72,6 +72,7 @@ use pocketmine\form\FormValidationException;
|
||||
use pocketmine\inventory\CraftingGrid;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\inventory\PlayerCursorInventory;
|
||||
use pocketmine\inventory\PlayerUIInventory;
|
||||
use pocketmine\inventory\transaction\action\InventoryAction;
|
||||
use pocketmine\inventory\transaction\CraftingTransaction;
|
||||
use pocketmine\inventory\transaction\InventoryTransaction;
|
||||
@ -289,8 +290,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
protected $windowIndex = [];
|
||||
/** @var bool[] */
|
||||
protected $permanentWindows = [];
|
||||
/** @var PlayerCursorInventory */
|
||||
protected $cursorInventory;
|
||||
/** @var PlayerUIInventory */
|
||||
protected $playerUIInventory;
|
||||
/** @var CraftingGrid */
|
||||
protected $craftingGrid = null;
|
||||
/** @var CraftingTransaction|null */
|
||||
@ -2718,6 +2719,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
|
||||
if($packet->action === InteractPacket::ACTION_MOUSEOVER and $packet->target === 0){
|
||||
//TODO HACK: silence useless spam (MCPE 1.8)
|
||||
//this packet is EXPECTED to only be sent when interacting with an entity, but due to some messy Mojang
|
||||
@ -3552,7 +3554,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$this->removeAllWindows(true);
|
||||
$this->windows = [];
|
||||
$this->windowIndex = [];
|
||||
$this->cursorInventory = null;
|
||||
$this->playerUIInventory = null;
|
||||
$this->craftingGrid = null;
|
||||
|
||||
if($this->constructed){
|
||||
@ -3817,16 +3819,19 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
$this->addWindow($this->getArmorInventory(), ContainerIds::ARMOR, true);
|
||||
|
||||
$this->cursorInventory = new PlayerCursorInventory($this);
|
||||
$this->addWindow($this->cursorInventory, ContainerIds::CURSOR, true);
|
||||
|
||||
$this->craftingGrid = new CraftingGrid($this, CraftingGrid::SIZE_SMALL);
|
||||
$this->playerUIInventory = new PlayerUIInventory($this);
|
||||
$this->addWindow($this->playerUIInventory, ContainerIds::UI, true);
|
||||
|
||||
$this->craftingGrid = new CraftingGrid($this->playerUIInventory, CraftingGrid::SIZE_SMALL);
|
||||
//TODO: more windows
|
||||
}
|
||||
|
||||
public function getPlayerUIInventory() : PlayerUIInventory{
|
||||
return $this->playerUIInventory;
|
||||
}
|
||||
|
||||
public function getCursorInventory() : PlayerCursorInventory{
|
||||
return $this->cursorInventory;
|
||||
return $this->playerUIInventory->getCursorInventory();
|
||||
}
|
||||
|
||||
public function getCraftingGrid() : CraftingGrid{
|
||||
@ -3842,7 +3847,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
public function doCloseInventory() : void{
|
||||
/** @var Inventory[] $inventories */
|
||||
$inventories = [$this->craftingGrid, $this->cursorInventory];
|
||||
$inventories = [$this->craftingGrid, $this->getCursorInventory()];
|
||||
foreach($inventories as $inventory){
|
||||
$contents = $inventory->getContents();
|
||||
if(count($contents) > 0){
|
||||
@ -3856,7 +3861,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
if($this->craftingGrid->getGridWidth() > CraftingGrid::SIZE_SMALL){
|
||||
$this->craftingGrid = new CraftingGrid($this, CraftingGrid::SIZE_SMALL);
|
||||
$this->craftingGrid = new CraftingGrid($this->playerUIInventory, CraftingGrid::SIZE_SMALL);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user