当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::getCustomBlockData方法代码示例

本文整理汇总了PHP中pocketmine\item\Item::getCustomBlockData方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getCustomBlockData方法的具体用法?PHP Item::getCustomBlockData怎么用?PHP Item::getCustomBlockData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\item\Item的用法示例。


在下文中一共展示了Item::getCustomBlockData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($player instanceof Player) {
         $pitch = $player->getPitch();
         if (abs($pitch) >= 45) {
             if ($pitch < 0) {
                 $f = 0;
             } else {
                 $f = 1;
             }
         } else {
             $f = $player->getDirection() + 2;
         }
     } else {
         $f = 0;
     }
     $faces = [0 => 0, 1 => 1, 2 => 4, 3 => 2, 4 => 5, 5 => 3];
     $this->meta = $faces[$f];
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::DROPPER), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
     $nbt->Items->setTagType(NBT::TAG_Compound);
     if ($item->hasCustomName()) {
         $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
     }
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     Tile::createTile(Tile::DROPPER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     return true;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:32,代码来源:Dropper.php

示例2: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($face !== 0) {
         $nbt = new CompoundTag("", ["id" => new StringTag("id", Tile::SIGN), "x" => new IntTag("x", $block->x), "y" => new IntTag("y", $block->y), "z" => new IntTag("z", $block->z), "Text1" => new StringTag("Text1", ""), "Text2" => new StringTag("Text2", ""), "Text3" => new StringTag("Text3", ""), "Text4" => new StringTag("Text4", "")]);
         if ($player !== null) {
             $nbt->Creator = new StringTag("Creator", $player->getRawUniqueId());
         }
         if ($item->hasCustomBlockData()) {
             foreach ($item->getCustomBlockData() as $key => $v) {
                 $nbt->{$key} = $v;
             }
         }
         if ($face === 1) {
             $this->meta = floor(($player->yaw + 180) * 16 / 360 + 0.5) & 0xf;
             $this->getLevel()->setBlock($block, Block::get(Item::SIGN_POST, $this->meta), true);
             Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt);
             return true;
         } else {
             $this->meta = $face;
             $this->getLevel()->setBlock($block, Block::get(Item::WALL_SIGN, $this->meta), true);
             Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt);
             return true;
         }
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:26,代码来源:SignPost.php

示例3: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $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:ClearSkyTeam,项目名称:ClearSky,代码行数:26,代码来源:EnchantingTable.php

示例4: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new CompoundTag("", [new StringTag("id", Tile::MOB_SPAWNER), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new IntTag("EntityId", 0)]);
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     Tile::createTile(Tile::MOB_SPAWNER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     return true;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:12,代码来源:MonsterSpawner.php

示例5: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $nbt = new CompoundTag("", [new StringTag("id", Tile::CAULDRON), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ShortTag("PotionId", 0xffff), new ByteTag("SplashPotion", 0), new ListTag("Items", [])]);
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     $chunk = $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4);
     $tile = Tile::createTile("Cauldron", $chunk, $nbt);
     $this->getLevel()->setBlock($block, $this, true, true);
     return true;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:13,代码来源:Cauldron.php

示例6: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new Compound("", [new String("id", Tile::ENCHANT_TABLE), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]);
     if ($item->hasCustomName()) {
         $nbt->CustomName = new String("CustomName", $item->getCustomName());
     }
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     return true;
 }
开发者ID:robozeri,项目名称:Yuriko-MP,代码行数:15,代码来源:EnchantingTable.php

示例7: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($this->getSide(Vector3::SIDE_DOWN)->isTransparent() === false) {
         $this->getLevel()->setBlock($block, $this, true, true);
         $nbt = new CompoundTag("", [new StringTag("id", Tile::FLOWER_POT), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ShortTag("item", 0), new IntTag("data", 0)]);
         if ($item->hasCustomBlockData()) {
             foreach ($item->getCustomBlockData() as $key => $v) {
                 $nbt->{$key} = $v;
             }
         }
         $pot = Tile::createTile("FlowerPot", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         return true;
     }
     return false;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:15,代码来源:FlowerPot.php

示例8: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $block->getSide(0);
     if ($down->isTransparent() === false || $down instanceof Slab && ($down->meta & 0x8) === 0x8 || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) {
         $this->getLevel()->setBlock($block, $this, true, true);
         $nbt = new CompoundTag("", [new StringTag("id", Tile::FLOWER_POT), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ShortTag("item", 0), new IntTag("mData", 0)]);
         if ($item->hasCustomBlockData()) {
             foreach ($item->getCustomBlockData() as $key => $v) {
                 $nbt->{$key} = $v;
             }
         }
         $pot = Tile::createTile("FlowerPot", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         return true;
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:16,代码来源:FlowerPot.php

示例9: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $faces = [0 => 4, 1 => 2, 2 => 5, 3 => 3];
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
     $this->getLevel()->setBlock($block, $this, true, true);
     $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);
     if ($item->hasCustomName()) {
         $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
     }
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     return true;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:18,代码来源:Furnace.php

示例10: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($block->getSide(Vector3::SIDE_DOWN)->isTransparent() === false) {
         $this->getLevel()->setBlock($block, $this, true, true);
         $nbt = new Compound("", [new String("id", Tile::BREWING_STAND), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]);
         if ($item->hasCustomName()) {
             $nbt->CustomName = new String("CustomName", $item->getCustomName());
         }
         if ($item->hasCustomBlockData()) {
             foreach ($item->getCustomBlockData() as $key => $v) {
                 $nbt->{$key} = $v;
             }
         }
         Tile::createTile(Tile::BREWING_STAND, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         return true;
     }
     return false;
 }
开发者ID:orlando092,项目名称:ImagicalMine,代码行数:18,代码来源:BrewingStand.php

示例11: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $faces = [0 => 4, 1 => 2, 2 => 5, 3 => 3];
     $chest = null;
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
     for ($side = 2; $side <= 5; ++$side) {
         if (($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)) {
             continue;
         } elseif (($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)) {
             continue;
         }
         $c = $this->getSide($side);
         if ($c instanceof Chest and $c->getDamage() === $this->meta) {
             $tile = $this->getLevel()->getTile($c);
             if ($tile instanceof TileChest and !$tile->isPaired()) {
                 $chest = $tile;
                 break;
             }
         }
     }
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new Compound("", [new Enum("Items", []), new String("id", Tile::CHEST), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]);
     $nbt->Items->setTagType(NBT::TAG_Compound);
     if ($item->hasCustomName()) {
         $nbt->CustomName = new String("CustomName", $item->getCustomName());
     }
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     $tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     if ($chest instanceof TileChest and $tile instanceof TileChest) {
         $chest->pairWith($tile);
         $tile->pairWith($chest);
     }
     return true;
 }
开发者ID:orlando092,项目名称:ImagicalMine,代码行数:38,代码来源:Chest.php

示例12: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $this->getSide(0);
     if ($face !== 0 && $fy > 0.5 && $target->getId() !== self::SKULL_BLOCK && !$down instanceof SkullBlock) {
         $this->getLevel()->setBlock($block, Block::get(Block::SKULL_BLOCK, 0), true, true);
         if ($face === 1) {
             $rot = new ByteTag("Rot", floor($player->yaw * 16 / 360 + 0.5) & 0xf);
         } else {
             $rot = new ByteTag("Rot", 0);
         }
         $nbt = new CompoundTag("", [new StringTag("id", Tile::SKULL), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ByteTag("SkullType", $item->getDamage()), $rot]);
         if ($item->hasCustomBlockData()) {
             foreach ($item->getCustomBlockData() as $key => $v) {
                 $nbt->{$key} = $v;
             }
         }
         $chunk = $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4);
         $pot = Tile::createTile(Tile::SKULL, $chunk, $nbt);
         $this->getLevel()->setBlock($block, Block::get(Block::SKULL_BLOCK, $face), true, true);
         return true;
     }
     return false;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:23,代码来源:SkullBlock.php

示例13: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($face > 1) {
         $faces = [2 => 3, 3 => 2, 4 => 1, 5 => 4];
         $itemTag = NBT::putItemHelper(Item::get(Item::AIR));
         $itemTag->setName("Item");
         $nbt = new CompoundTag("", [new StringTag("id", MainClass::TILE_ITEM_FRAME), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new CompoundTag("Item", $itemTag->getValue()), new FloatTag("ItemDropChance", 1.0), new ByteTag("ItemRotation", 0)]);
         if ($item->hasCustomBlockData()) {
             foreach ($item->getCustomBlockData() as $key => $value) {
                 //Reformat: support "Item" tag by give command
                 if ($key === "Item" and $value instanceof CompoundTag) {
                     $value = NBT::putItemHelper(NBT::getItemHelper($value));
                     $value->setName("Item");
                 }
                 $nbt->{$key} = $value;
             }
         }
         //var_dump($nbt);//debug
         Tile::createTile("ItemFrame", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         $this->getLevel()->setBlock($block, Block::get(MainClass::BLOCK_ITEM_FRAME, $faces[$face]), true, true);
         return true;
     }
     return false;
 }
开发者ID:beito123,项目名称:PocketMine-MP-Plugins,代码行数:24,代码来源:BlockItemFrame.php

示例14: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if (!$this->getLevel()->getServer()->enchantingTableEnabled) {
         return true;
     }
     if ($player instanceof Player) {
         //TODO lock
         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;
             }
         }
         $enchantTable = Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     }
     $player->addWindow($enchantTable->getInventory());
     return true;
 }
开发者ID:AnonymousProjects,项目名称:PocketMine-MP-Original,代码行数:31,代码来源:EnchantingTable.php

示例15: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false and $face > 1 and $block->isSolid() === false) {
         $faces = [2 => 3, 3 => 2, 4 => 1, 5 => 0];
         $this->meta = $faces[$face];
         $this->getLevel()->setBlock($block, $this, true, true);
         $nbt = new CompoundTag("", [new StringTag("id", Tile::ITEM_FRAME), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ByteTag("ItemRotation", 0), new FloatTag("ItemDropChance", 1.0)]);
         if ($item->hasCustomBlockData()) {
             foreach ($item->getCustomBlockData() as $key => $v) {
                 $nbt->{$key} = $v;
             }
         }
         Tile::createTile(Tile::ITEM_FRAME, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         return true;
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:17,代码来源:ItemFrame.php


注:本文中的pocketmine\item\Item::getCustomBlockData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。