本文整理汇总了PHP中pocketmine\level\Level::getChunkAt方法的典型用法代码示例。如果您正苦于以下问题:PHP Level::getChunkAt方法的具体用法?PHP Level::getChunkAt怎么用?PHP Level::getChunkAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\level\Level
的用法示例。
在下文中一共展示了Level::getChunkAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
}
示例2: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$entity = null;
$chunk = $level->getChunkAt($block->getX() >> 4, $block->getZ() >> 4);
if (!$chunk instanceof FullChunk) {
return false;
}
$nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $block->getX()), new Double("", $block->getY()), new Double("", $block->getZ())]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", lcg_value() * 360), new Float("", 0)])]);
switch ($this->meta) {
case Villager::NETWORK_ID:
$nbt->Health = new Short("Health", 20);
$entity = new Villager($chunk, $nbt);
break;
case Zombie::NETWORK_ID:
$nbt->Health = new Short("Health", 20);
$entity = new Zombie($chunk, $nbt);
break;
/*
//TODO: use entity constants
case 10:
case 11:
case 12:
case 13:
$data = array(
"x" => $block->x + 0.5,
"y" => $block->y,
"z" => $block->z + 0.5,
);
//$e = Server::getInstance()->api->entity->add($block->level, ENTITY_MOB, $this->meta, $data);
//Server::getInstance()->api->entity->spawnToAll($e);
if(($player->gamemode & 0x01) === 0){
--$this->count;
}
return true;*/
}
if ($entity instanceof Entity) {
if (($player->gamemode & 0x1) === 0) {
--$this->count;
}
$entity->spawnToAll();
return true;
}
return false;
}