当前位置: 首页>>代码示例>>PHP>>正文


PHP Level::getChunkAt方法代码示例

本文整理汇总了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);
             }
         }
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:15,代码来源:Leash.php

示例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;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:45,代码来源:SpawnEgg.php


注:本文中的pocketmine\level\Level::getChunkAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。