本文整理汇总了PHP中Block::getMetadata方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::getMetadata方法的具体用法?PHP Block::getMetadata怎么用?PHP Block::getMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block::getMetadata方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($this->meta === AIR) {
if ($target instanceof LiquidBlock) {
$level->setBlock($target, new AirBlock(), true, false, true);
if (($player->gamemode & 0x1) === 0) {
$this->meta = $target instanceof WaterBlock ? WATER : LAVA;
}
return true;
}
} elseif ($this->meta === WATER) {
//Support Make Non-Support Water to Support Water
if ($block->getID() === AIR || $block instanceof WaterBlock && ($block->getMetadata() & 0x7) != 0x0) {
$water = new WaterBlock();
$level->setBlock($block, $water, true, false, true);
$water->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
if (($player->gamemode & 0x1) === 0) {
$this->meta = 0;
}
return true;
}
} elseif ($this->meta === LAVA) {
if ($block->getID() === AIR) {
$level->setBlock($block, new LavaBlock(), true, false, true);
if (($player->gamemode & 0x1) === 0) {
$this->meta = 0;
}
return true;
}
}
return false;
}
示例2: place
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$this->meta &= 0x7;
if ($face === 0) {
if ($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x8) === 0x8 and ($target->getMetadata() & 0x7) === ($this->meta & 0x7)) {
$this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true;
} elseif ($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x7) === ($this->meta & 0x7)) {
$this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true;
} else {
$this->meta |= 0x8;
}
} elseif ($face === 1) {
if ($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x8) === 0 and ($target->getMetadata() & 0x7) === ($this->meta & 0x7)) {
$this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true;
} elseif ($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x7) === ($this->meta & 0x7)) {
$this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true;
}
} elseif (!$player->entity->inBlock($block)) {
if ($block->getID() === WOOD_SLAB) {
if (($block->getMetadata() & 0x7) === ($this->meta & 0x7)) {
$this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true;
}
return false;
} else {
if ($fy > 0.5) {
$this->meta |= 0x8;
}
}
} else {
return false;
}
if ($block->getID() === WOOD_SLAB and ($target->getMetadata() & 0x7) !== ($this->meta & 0x7)) {
return false;
}
$this->level->setBlock($block, $this, true, false, true);
return true;
}
示例3: setBlock
public function setBlock(Vector3 $pos, Block $block, $update = true, $tiles = false, $direct = false)
{
if (!isset($this->level) or $pos instanceof Position and $pos->level !== $this or $pos->x < 0 or $pos->y < 0 or $pos->z < 0) {
return false;
}
$ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata());
if ($ret === true) {
if (!$pos instanceof Position) {
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
}
$block->position($pos);
if ($direct === true) {
$pk = new UpdateBlockPacket();
$pk->x = $pos->x;
$pk->y = $pos->y;
$pk->z = $pos->z;
$pk->block = $block->getID();
$pk->meta = $block->getMetadata();
$this->server->api->player->broadcastPacket($this->players, $pk);
} else {
$i = ($pos->x >> 4) . ":" . ($pos->y >> 4) . ":" . ($pos->z >> 4);
if (!isset($this->changedBlocks[$i])) {
$this->changedBlocks[$i] = array();
$this->changedCount[$i] = 0;
}
if (ADVANCED_CACHE == true) {
Cache::remove("world:{$this->name}:" . ($pos->x >> 4) . ":" . ($pos->z >> 4));
}
$this->changedBlocks[$i][] = clone $block;
++$this->changedCount[$i];
}
if ($update === true) {
$this->server->api->block->blockUpdateAround($pos, BLOCK_UPDATE_NORMAL, 1);
$this->server->api->entity->updateRadius($pos, 3);
}
if ($tiles === true) {
if (($t = $this->server->api->tile->get($pos)) !== false) {
$t->close();
}
}
}
return $ret;
}
示例4: cancelAction
private function cancelAction(Block $block, Player $player, $send = true)
{
$pk = new UpdateBlockPacket();
$pk->x = $block->x;
$pk->y = $block->y;
$pk->z = $block->z;
$pk->block = $block->getID();
$pk->meta = $block->getMetadata();
$player->dataPacket($pk);
if ($send === true) {
$player->sendInventorySlot($player->slot);
}
return false;
}