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

@ -30,6 +30,7 @@ use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\event\server\DataPacketSendEvent;
use pocketmine\form\Form;
use pocketmine\GameMode;
use pocketmine\inventory\CreativeInventory;
use pocketmine\inventory\Inventory;
use pocketmine\math\Vector3;
use pocketmine\network\BadPacketException;
@ -774,6 +775,17 @@ class NetworkSession{
}
}
public function syncCreativeInventoryContents() : void{
$items = [];
if(!$this->player->isSpectator()){ //fill it for all gamemodes except spectator
foreach(CreativeInventory::getAll() as $i => $item){
$items[$i] = clone $item;
}
}
$this->sendDataPacket(InventoryContentPacket::create(ContainerIds::CREATIVE, $items));
}
public function onMobArmorChange(Living $mob) : void{
$inv = $mob->getArmorInventory();
$this->sendDataPacket(MobArmorEquipmentPacket::create($mob->getId(), $inv->getHelmet(), $inv->getChestplate(), $inv->getLeggings(), $inv->getBoots()));