本文整理汇总了PHP中pocketmine\level\Level::addEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP Level::addEntity方法的具体用法?PHP Level::addEntity怎么用?PHP Level::addEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\level\Level
的用法示例。
在下文中一共展示了Level::addEntity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if (!$target instanceof Fence) {
return false;
}
foreach ($level->getChunkEntities($target->x >> 4, $target->z >> 4) as $entity) {
if ($entity->isLeashed()) {
if ($entity->leadHolder === $player->getId()) {
$nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $block->getX() + 0.5), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ() + 0.5)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", lcg_value() * 360), new FloatTag("", 0)])]);
$level->addEntity($knot = new LeashKnot($level->getChunkAt($target->x >> 4, $target->z >> 4), $nbt));
$entity->setLeashHolder($knot);
}
}
}
}