Moved creative inventory sync to NetworkSession

This commit is contained in:
Dylan K. Taylor
2019-06-10 19:54:24 +01:00
parent dd45753fa9
commit f0d56f25b6
4 changed files with 14 additions and 20 deletions

View File

@@ -25,7 +25,6 @@ namespace pocketmine\inventory;
use pocketmine\entity\Human;
use pocketmine\item\Item;
use pocketmine\network\mcpe\protocol\InventoryContentPacket;
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
use pocketmine\network\mcpe\protocol\types\ContainerIds;
use pocketmine\Player;
@@ -156,23 +155,6 @@ class PlayerInventory extends BaseInventory{
return 9;
}
public function sendCreativeContents() : void{
//TODO: this mess shouldn't be in here
$holder = $this->getHolder();
if(!($holder instanceof Player)){
throw new \LogicException("Cannot send creative inventory contents to non-player inventory holder");
}
$items = [];
if(!$holder->isSpectator()){ //fill it for all gamemodes except spectator
foreach(CreativeInventory::getAll() as $i => $item){
$items[$i] = clone $item;
}
}
$holder->sendDataPacket(InventoryContentPacket::create(ContainerIds::CREATIVE, $items));
}
/**
* This override is here for documentation and code completion purposes only.
* @return Human|Player