本文整理匯總了PHP中pocketmine\item\Item::hasCustomName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::hasCustomName方法的具體用法?PHP Item::hasCustomName怎麽用?PHP Item::hasCustomName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\item\Item
的用法示例。
在下文中一共展示了Item::hasCustomName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
if ($face !== 0) {
$this->meta = $face;
if ($face === 1) {
$rot = floor($player->yaw * 16 / 360 + 0.5) & 0xf;
} else {
$rot = $face;
}
$this->getLevel()->setBlock($block, $this, true);
$nbt = new CompoundTag("", [new StringTag("id", Tile::SKULL), new ByteTag("SkullType", $item->getDamage()), new ByteTag("Rot", $rot), new IntTag("x", (int) $this->x), new IntTag("y", (int) $this->y), new IntTag("z", (int) $this->z)]);
if ($item->hasCustomName()) {
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
}
/** @var Spawnable $tile */
Tile::createTile("Skull", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
return true;
}
return false;
}
示例7: 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 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);
if ($item->hasCustomName()) {
$nbt->CustomName = new StringTag("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;
}
示例8: 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;
}