本文整理汇总了PHP中pocketmine\block\Block::isCharged方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::isCharged方法的具体用法?PHP Block::isCharged怎么用?PHP Block::isCharged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\block\Block
的用法示例。
在下文中一共展示了Block::isCharged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$down = $this->getSide(0);
if ($target->isTransparent() === false and $face !== 0) {
$faces = [1 => 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1];
$this->meta = $faces[$face];
$side = $faces[$face];
$faces = [1 => 4, 2 => 5, 3 => 2, 4 => 3, 5 => 0, 6 => 0, 0 => 0];
if ($this->getSide($faces[$side])->isCharged($this->getHash())) {
$this->id = 75;
$this->getLevel()->setBlock($block, $this);
return;
}
$this->getLevel()->setBlock($block, $this);
$this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, Block::REDSTONESOURCEPOWER);
return true;
} elseif ($down->isTransparent() === false or $down->getId() === self::FENCE or $down->getId() === self::COBBLE_WALL or $down->getId() === self::GLASS || $down instanceof Slab && ($down->meta & 0x8) === 0x8 || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) {
$this->meta = 0;
if ($target->isCharged($this->getHash())) {
$this->id = 75;
$this->getLevel()->setBlock($block, $this);
return;
}
$this->getLevel()->setBlock($block, $this);
$this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, Block::REDSTONESOURCEPOWER);
return true;
}
return false;
}
示例2: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$below = $this->getSide(0);
if ($target->isTransparent() === false and $face !== 0) {
$faces = [1 => 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1];
$this->meta = $faces[$face];
if ($target->isCharged()) {
$this->id = 75;
$this->getLevel()->setBlock($block, $this);
return;
}
$this->getLevel()->setBlock($block, $this);
$this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, $this->getPower());
$this->getLevel()->scheduleUpdate($this->getSide(Vector3::SIDE_UP), 2);
// 2 ticks = 1 redstone tick
return true;
} elseif ($below->isTransparent() === false or $below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL) {
$this->meta = 0;
if ($target->isCharged()) {
$this->id = 75;
$this->getLevel()->setBlock($block, $this);
return;
}
$this->getLevel()->setBlock($block, $this);
$this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, $this->getPower());
$this->getLevel()->scheduleUpdate($this->getSide(Vector3::SIDE_UP), 2);
return true;
}
return false;
}