diff --git a/src/Player.php b/src/Player.php index 45c9e3dde..f499c4883 100644 --- a/src/Player.php +++ b/src/Player.php @@ -467,7 +467,7 @@ class Player extends PlayerEntity{ //Normal inventory $slotCount = (($this->gamemode & 0x01) === 0 ? PLAYER_SURVIVAL_SLOTS:PLAYER_CREATIVE_SLOTS) + 9; for($slot = 9; $slot < $slotCount; ++$slot){ - $item = $this->getSlot($count); + $item = $this->getSlot($slot); $this->namedtag->Inventory[$slot] = new NBTTag_Compound(false, array( "Count" => new NBTTag_Byte("Count", $item->getCount()), "Damage" => new NBTTag_Short("Damage", $item->getMetadata()), diff --git a/src/entity/HumanEntity.php b/src/entity/HumanEntity.php index 29882ddf2..96c516978 100644 --- a/src/entity/HumanEntity.php +++ b/src/entity/HumanEntity.php @@ -215,7 +215,11 @@ class HumanEntity extends CreatureEntity implements ProjectileSourceEntity, Inve } public function getSlot($slot){ - $this->inventory[(int) $slot] = $item; + $slot = (int) $slot; + if(!($this->inventory[$slot] instanceof Item)){ + $this->inventory[$slot] = BlockAPI::getItem(AIR, 0, 0); + } + return $this->inventory[$slot]; } public function getAllSlots(){