當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Player::addWindow方法代碼示例

本文整理匯總了PHP中pocketmine\Player::addWindow方法的典型用法代碼示例。如果您正苦於以下問題:PHP Player::addWindow方法的具體用法?PHP Player::addWindow怎麽用?PHP Player::addWindow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\Player的用法示例。


在下文中一共展示了Player::addWindow方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if (!$this->getLevel()->getServer()->enchantingTableEnabled) {
         return true;
     }
     if ($player instanceof Player) {
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $tile = $this->getLevel()->getTile($this);
         $enchantTable = null;
         if ($tile instanceof EnchantTable) {
             $enchantTable = $tile;
         } else {
             $this->getLevel()->setBlock($this, $this, true, true);
             $nbt = new CompoundTag("", [new StringTag("id", Tile::ENCHANT_TABLE), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             if ($item->hasCustomName()) {
                 $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
             }
             if ($item->hasCustomBlockData()) {
                 foreach ($item->getCustomBlockData() as $key => $v) {
                     $nbt->{$key} = $v;
                 }
             }
             /** @var EnchantTable $enchantTable */
             $enchantTable = Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         $player->addWindow(new EnchantInventory($this));
         $player->craftingType = Player::CRAFTING_ENCHANT;
     }
     return true;
 }
開發者ID:iTXTech,項目名稱:Genisys,代碼行數:32,代碼來源:EnchantingTable.php

示例2: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $t = $this->getLevel()->getTile($this);
         $dispenser = null;
         if ($t instanceof TileDispenser) {
             $dispenser = $t;
         } else {
             $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::DISPENSER), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $dispenser = Tile::createTile(Tile::DISPENSER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $player->addWindow($dispenser->getInventory());
     }
     return true;
 }
開發者ID:iTXTech,項目名稱:Genisys,代碼行數:19,代碼來源:Dispenser.php

示例3: openShop

 public function openShop(Player $player)
 {
     $chestBlock = new \pocketmine\block\Chest();
     $player->getLevel()->setBlock(new Vector3($player->getX(), $player->getY() - 4, $player->getZ()), $chestBlock, true, true);
     $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $player->getX()), new IntTag("y", $player->getY() - 4), new IntTag("z", $player->getZ())]);
     $nbt->Items->setTagType(NBT::TAG_Compound);
     $tile = Tile::createTile("Chest", $player->getLevel()->getChunk($player->getX() >> 4, $player->getZ() >> 4), $nbt);
     if ($tile instanceof Chest) {
         $config = new Config($this->getDataFolder() . "shop.yml", Config::YAML);
         $all = $config->get("Shop");
         $tile->getInventory()->clearAll();
         for ($i = 0; $i < count($all); $i += 2) {
             $slot = $i / 2;
             $tile->getInventory()->setItem($slot, Item::get($all[$i], 0, 1));
         }
         $tile->getInventory()->setItem($tile->getInventory()->getSize() - 1, Item::get(Item::WOOL, 14, 1));
         $player->addWindow($tile->getInventory());
     }
 }
開發者ID:Bluplayz,項目名稱:BedwarsPE,代碼行數:19,代碼來源:Bedwars.php

示例4: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $t = $this->getLevel()->getTile($this);
         if ($t instanceof FurnaceTile) {
             $furnace = $t;
         } else {
             $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::FURNACE), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         if (isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof StringTag) {
             if ($furnace->namedtag->Lock->getValue() !== $item->getCustomName()) {
                 return true;
             }
         }
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $player->addWindow($furnace->getInventory());
     }
     return true;
 }
開發者ID:iTXTech,項目名稱:Genisys,代碼行數:23,代碼來源:Furnace.php

示例5: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $top = $this->getSide(1);
         if ($top->isTransparent() !== true) {
             return true;
         }
         $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, Block::REDSTONESOURCEPOWER);
         $this->getLevel()->scheduleUpdate($this, 2);
         $t = $this->getLevel()->getTile($this);
         $chest = null;
         if ($t instanceof TileChest) {
             $chest = $t;
         } else {
             $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         if (isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag) {
             if ($chest->namedtag->Lock->getValue() !== $item->getCustomName()) {
                 return true;
             }
         }
         $player->addWindow($chest->getInventory());
     }
     return true;
 }
開發者ID:ClearSkyTeam,項目名稱:ClearSky,代碼行數:27,代碼來源:TrappedChest.php

示例6: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $top = $this->getSide(1);
         if ($top->isTransparent() !== true) {
             return true;
         }
         $t = $this->getLevel()->getTile($this);
         $chest = null;
         if ($t instanceof TileChest) {
             $chest = $t;
         } else {
             $nbt = new CompoundTag("", [new EnumTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         if (isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag) {
             if ($chest->namedtag->Lock->getValue() !== $item->getCustomName()) {
                 return true;
             }
         }
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $player->addWindow($chest->getInventory());
     }
     return true;
 }
開發者ID:xpyctum,項目名稱:Genisys,代碼行數:28,代碼來源:Chest.php

示例7: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $player->addWindow(new AnvilInventory($this));
     }
     return true;
 }
開發者ID:xxFlare,項目名稱:PocketMine-MP,代碼行數:7,代碼來源:Anvil.php

示例8: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         //TODO lock
         $player->addWindow(new EnchantInventory($this));
     }
     return true;
 }
開發者ID:xxFlare,項目名稱:PocketMine-MP,代碼行數:8,代碼來源:EnchantingTable.php

示例9: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $player->addWindow(new AnvilInventory($this));
         $player->craftingType = Player::CRAFTING_ANVIL;
     }
     return true;
 }
開發者ID:ClearSkyTeam,項目名稱:ClearSky,代碼行數:8,代碼來源:Anvil.php

示例10: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         if ($player->isCreative()) {
             return true;
         }
         $player->addWindow(new BrewingInventory($this));
     }
     return true;
 }
開發者ID:TexusDark,項目名稱:Ananas-MP,代碼行數:10,代碼來源:BrewingStand.php

示例11: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         //TODO lock
         if ($player->isCreative()) {
             return true;
         }
         if (($t = $this->getLevel()->getTile($this)) instanceof TileBrewingStand) {
             $player->addWindow(new BrewingInventory($t));
         }
     }
     return true;
 }
開發者ID:orlando092,項目名稱:ImagicalMine,代碼行數:13,代碼來源:BrewingStand.php

示例12: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if (!$this->getLevel()->getServer()->anviletEnabled) {
         return true;
     }
     if ($player instanceof Player) {
         if ($player->isCreative()) {
             return true;
         }
         $player->addWindow(new AnvilInventory($this));
     }
     return true;
 }
開發者ID:PepbookPvP,項目名稱:Genisys,代碼行數:13,代碼來源:Anvil.php

示例13: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $t = $this->getLevel()->getTile($this);
         if ($t instanceof TileHopper) {
             if ($t->hasLock() and !$t->checkLock($item->getCustomName())) {
                 $player->getServer()->getLogger()->debug($player->getName() . " attempted to open a locked hopper");
                 return true;
             }
             $player->addWindow($t->getInventory());
         }
     }
     return true;
 }
開發者ID:iTXTech,項目名稱:Genisys,代碼行數:14,代碼來源:Hopper.php

示例14: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if (!$this->getLevel()->getServer()->anvilEnabled) {
         return true;
     }
     if ($player instanceof Player) {
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $player->addWindow(new AnvilInventory($this));
         $player->craftingType = Player::CRAFTING_ANVIL;
     }
     return true;
 }
開發者ID:iTXTech,項目名稱:Genisys,代碼行數:14,代碼來源:Anvil.php

示例15: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         //TODO lock
         $t = $this->getLevel()->getTile($this);
         //$brewingStand = false;
         if ($t instanceof TileBrewingStand) {
             $brewingStand = $t;
         } else {
             $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::BREWING_STAND), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $brewingStand = Tile::createTile(Tile::BREWING_STAND, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         $player->addWindow($brewingStand->getInventory());
     }
     return true;
 }
開發者ID:ClearSkyTeam,項目名稱:ClearSky,代碼行數:17,代碼來源:BrewingStand.php


注:本文中的pocketmine\Player::addWindow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。