mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Inventory: Fix creative/spectator inventory sending
This commit is contained in:
@ -58,7 +58,7 @@ class InventoryType{
|
||||
|
||||
static::$default[static::CHEST] = new InventoryType(27, "Chest", 0);
|
||||
static::$default[static::DOUBLE_CHEST] = new InventoryType(27 + 27, "DoubleTag Chest", 0);
|
||||
static::$default[static::PLAYER] = new InventoryType(49, "Player", 0); //36 CONTAINER, 4 ARMOR (9 reference HOTBAR slots)
|
||||
static::$default[static::PLAYER] = new InventoryType(36 + 4, "Player", 0); //36 CONTAINER, 4 ARMOR
|
||||
static::$default[static::FURNACE] = new InventoryType(3, "Furnace", 2);
|
||||
static::$default[static::CRAFTING] = new InventoryType(5, "Crafting", 1); //4 CRAFTING slots, 1 RESULT
|
||||
static::$default[static::WORKBENCH] = new InventoryType(10, "Crafting", 1); //9 CRAFTING slots, 1 RESULT
|
||||
|
@ -384,16 +384,14 @@ class PlayerInventory extends BaseInventory{
|
||||
|
||||
$pk = new ContainerSetContentPacket();
|
||||
$pk->slots = [];
|
||||
$holder = $this->getHolder();
|
||||
if($holder instanceof Player and $holder->isCreative()){
|
||||
//TODO: Remove this workaround because of broken client
|
||||
foreach(Item::getCreativeItems() as $i => $item){
|
||||
$pk->slots[$i] = Item::getCreativeItem($i);
|
||||
}
|
||||
}else{
|
||||
for($i = 0; $i < $this->getSize(); ++$i){ //Do not send armor by error here
|
||||
$pk->slots[$i] = $this->getItem($i);
|
||||
}
|
||||
|
||||
for($i = 0; $i < $this->getSize(); ++$i){ //Do not send armor by error here
|
||||
$pk->slots[$i] = $this->getItem($i);
|
||||
}
|
||||
|
||||
//Because PE is stupid and shows 9 less slots than you send it, give it 9 dummy slots so it shows all the REAL slots.
|
||||
for($i = $this->getSize(); $i < $this->getSize() + $this->getHotbarSize(); ++$i){
|
||||
$pk->slots[$i] = Item::get(Item::AIR, 0, 0);
|
||||
}
|
||||
|
||||
foreach($target as $player){
|
||||
@ -401,7 +399,16 @@ class PlayerInventory extends BaseInventory{
|
||||
if($player === $this->getHolder()){
|
||||
for($i = 0; $i < $this->getHotbarSize(); ++$i){
|
||||
$index = $this->getHotbarSlotIndex($i);
|
||||
$pk->hotbar[] = $index <= -1 ? -1 : $index + 9;
|
||||
$pk->hotbar[] = $index <= -1 ? -1 : $index + $this->getHotbarSize();
|
||||
}
|
||||
|
||||
if($player->getGamemode() & 0x01 === 0x01){ //Send special inventory for creative or spectator
|
||||
$pk2 = new ContainerSetContentPacket();
|
||||
$pk2->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE;
|
||||
if($player->getGamemode() === Player::CREATIVE){
|
||||
$pk2->slots = Item::getCreativeItems();
|
||||
}
|
||||
$player->dataPacket($pk2);
|
||||
}
|
||||
}
|
||||
if(($id = $player->getWindowId($this)) === -1 or $player->spawned !== true){
|
||||
|
Reference in New Issue
Block a user