当前位置: 首页>>代码示例>>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;未经允许,请勿转载。