本文整理汇总了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;
}
示例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;
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例7: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($player instanceof Player) {
$player->addWindow(new AnvilInventory($this));
}
return true;
}
示例8: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($player instanceof Player) {
//TODO lock
$player->addWindow(new EnchantInventory($this));
}
return true;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}