getWindowId() public method

public getWindowId ( pocketmine\inventory\Inventory $inventory ) : integer
$inventory pocketmine\inventory\Inventory
return integer
 public function onClose(Player $who)
 {
     $pk = new ContainerClosePacket();
     $pk->windowid = $who->getWindowId($this);
     $who->dataPacket($pk);
     parent::onClose($who);
 }
 public function onClose(Player $who)
 {
     $pk = new ContainerClosePacket();
     $pk->windowid = $who->getWindowId($this);
     $who->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
     parent::onClose($who);
 }
Esempio n. 3
0
 public static function fillUpChest(Block $chest, Player $player)
 {
     if ($chest->getId() == Item::CHEST || $chest->getId()) {
         if ($player->gamemode == Player::CREATIVE) {
             $player->sendMessage("[HG] You are in creative Mode");
             return;
         }
         if (!$player->isOp()) {
             $pk = new ContainerSetContentPacket();
             $pk->windowid = $player->getWindowId($player->getInventory());
             // ContainerSetContentPacket::SPECIAL_INVENTORY;
             for ($i = 1; $i < 5; $i++) {
                 $pk->slots[] = HungerGameKit::randomItems();
             }
             $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
             if ($player->getInventory() != null) {
                 $player->getInventory()->sendContents($player);
             }
             // $player->sendMessage ( "[HG] openning chest" );
         }
     }
 }
Esempio n. 4
0
 public static function openChest(Block $chest, Player $player)
 {
     if ($chest->getId() == Item::CHEST) {
         if ($player->gamemode == Player::CREATIVE) {
             $player->sendMessage("[HG] You are in creative Mode");
             return;
         }
         if (!$player->isOp()) {
             $pk = new ContainerOpenPacket();
             $pk->windowid = $player->getWindowId($player->getInventory());
             $pk->type = InventoryType::CHEST;
             $pk->slots = $player->getInventory()->getSize();
             $pk->x = $chest->x;
             $pk->y = $chest->y;
             $pk->z = $chest->z;
             $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
             $player->getInventory()->sendContents($player);
         }
     }
 }