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


PHP entity\Animal类代码示例

本文整理汇总了PHP中pocketmine\entity\Animal的典型用法代码示例。如果您正苦于以下问题:PHP Animal类的具体用法?PHP Animal怎么用?PHP Animal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Animal类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: spawnToAll

 public function spawnToAll()
 {
     parent::spawnToAll();
     if ($this->getLevel()->getServer()->lightningFire) {
         $fire = ItemItem::get(ItemItem::FIRE)->getBlock();
         $oldBlock = $this->getLevel()->getBlock($this);
         if ($oldBlock instanceof Liquid) {
         } elseif ($oldBlock->isSolid()) {
             $v3 = new Vector3($this->x, $this->y + 1, $this->z);
         } else {
             $v3 = new Vector3($this->x, $this->y, $this->z);
         }
         if (isset($v3)) {
             $this->getLevel()->setBlock($v3, $fire);
         }
         foreach ($this->level->getNearbyEntities($this->boundingBox->grow(4, 3, 4), $this) as $entity) {
             if ($entity instanceof Player) {
                 $damage = mt_rand(8, 20);
                 $ev = new EntityDamageByEntityEvent($this, $entity, EntityDamageByEntityEvent::CAUSE_LIGHTNING, $damage);
                 if ($entity->attack($ev->getFinalDamage(), $ev) === true) {
                     $ev->useArmors();
                 }
                 $entity->setOnFire(mt_rand(3, 8));
             }
             if ($entity instanceof Creeper) {
                 $entity->setPowered(true, $this);
             }
         }
     }
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:30,代码来源:Lightning.php

示例2: spawnTo

 public function spawnTo(Player $player)
 {
     $pk = $this->addEntityDataPacket($player);
     $pk->type = Mooshroom::NETWORK_ID;
     $player->dataPacket($pk);
     parent::spawnTo($player);
 }
开发者ID:kiyoshi-kurosaki,项目名称:ClearSky,代码行数:7,代码来源:Mooshroom.php

示例3: spawnTo

 public function spawnTo(Player $player)
 {
     $pk = new AddEntityPacket();
     $pk->eid = $this->getId();
     $pk->type = Wolf::NETWORK_ID;
     $pk->x = $this->x;
     $pk->y = $this->y;
     $pk->z = $this->z;
     $pk->speedX = $this->motionX;
     $pk->speedY = $this->motionY;
     $pk->speedZ = $this->motionZ;
     $pk->yaw = $this->yaw;
     $pk->pitch = $this->pitch;
     $pk->metadata = $this->dataProperties;
     $player->dataPacket($pk);
     parent::spawnTo($player);
 }
开发者ID:1455931078,项目名称:Genisys,代码行数:17,代码来源:Wolf.php

示例4: spawnTo

 public function spawnTo(Player $player)
 {
     $pk = new AddEntityPacket();
     $pk->eid = $this->getId();
     $pk->type = Pig::NETWORK_ID;
     $pk->x = $this->x;
     $pk->y = $this->y;
     $pk->z = $this->z;
     $pk->speedX = $this->motionX;
     $pk->speedY = $this->motionY;
     $pk->speedZ = $this->motionZ;
     $pk->yaw = $this->yaw;
     $pk->pitch = $this->pitch;
     $pk->metadata = $this->dataProperties;
     $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
     parent::spawnTo($player);
 }
开发者ID:misha1,项目名称:MyOwnWorld,代码行数:17,代码来源:Pig.php

示例5: spawnTo

 public function spawnTo(Player $player)
 {
     $pk = new AddEntityPacket();
     $pk->eid = $this->getId();
     $pk->type = self::NETWORK_ID;
     $pk->x = $this->x;
     $pk->y = $this->y;
     $pk->z = $this->z;
     $pk->speedX = $this->motionX;
     $pk->speedY = 1.5;
     $pk->speedZ = $this->motionZ;
     $pk->yaw = $this->yaw;
     $pk->pitch = $this->pitch;
     $pk->metadata = [Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $this->getDataProperty(2)], Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 1], Entity::DATA_NO_AI => [Entity::DATA_TYPE_BYTE, 1]];
     $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
     parent::spawnTo($player);
 }
开发者ID:gitter-badger,项目名称:Development-1,代码行数:17,代码来源:SlapperWolf.php

示例6: knockBack

 public function knockBack(Entity $attacker, $damage, $x, $z, $base = 0.4)
 {
     parent::knockBack($attacker, $damage, $x, $z, $base);
     $this->knockback = time() + 1;
     // Stunned for 1 second...
 }
开发者ID:AvivShopen,项目名称:bad-plugins,代码行数:6,代码来源:Chicken.php

示例7: onUpdate

 public function onUpdate($currentTick)
 {
     $hasUpdate = false;
     $this->timings->startTiming();
     // Handle flying objects...
     $tickDiff = max(1, $currentTick - $this->lastUpdate);
     $bb = clone $this->getBoundingBox();
     $onGround = count($this->level->getCollisionBlocks($bb->offset(0, -$this->gravity, 0))) > 0;
     if (!$onGround) {
         // falling or jumping...
         $this->motionY -= $this->gravity;
         $this->x += $this->motionX * $tickDiff;
         $this->y += $this->motionY * $tickDiff;
         $this->z += $this->motionZ * $tickDiff;
         //echo ("Falling...\n");
     } else {
         $this->motionX = 0;
         // No longer jumping/falling
         $this->motionY = 0;
         $this->motionZ = 0;
         if ($this->y != floor($this->y)) {
             $this->y = floor($this->y);
         }
         // Try to attack a player
         $target = null;
         if ($this->petOwner->player) {
             $target = $this->petOwner->player;
             if ($target) {
                 if ($target->getLevel() != $this->level) {
                     // Pet is in a different level...
                     $target = null;
                 } else {
                     $dist = $this->distance($target);
                 }
             }
         }
         // if no target despawn
         if ($target === null) {
             $this->close();
             return;
         }
         if ($target !== null && $dist != 0) {
             $dir = $target->getLevel()->getSafeSpawn($target)->subtract($this);
             $dir = $dir->divide($dist);
             $this->yaw = rad2deg(atan2(-$dir->getX(), $dir->getZ()));
             $this->pitch = rad2deg(atan(-$dir->getY()));
             // if dist to owner < move dist or pet is being told to stay just look at owner
             if ($dist <= self::$dist || $this->isSitting) {
                 //$this->yaw = rad2deg(atan2(-$dir->getX(),$dir->getZ()));
                 //$this->pitch = rad2deg(atan(-$dir->getY()));
                 $this->updateMovement();
                 $this->level->addEntityMovement($this->chunk->getX(), $this->chunk->getZ(), $this->id, $this->x, $this->y, $this->z, $this->yaw, $this->pitch, $this->yaw);
             }
             // otherwise do a full movement
             if ($dist > self::$dist && !$this->isSitting) {
                 $x = $dir->getX() * self::$speed;
                 $y = 0;
                 $z = $dir->getZ() * self::$speed;
                 $isJump = count($this->level->getCollisionBlocks($bb->offset($x, 1.2, $z))) <= 0;
                 if (count($this->level->getCollisionBlocks($bb->offset(0, 0.1, $z))) > 0) {
                     if ($isJump) {
                         $y = self::$jump;
                         $this->motionZ = $z;
                     }
                     $z = 0;
                 }
                 if (count($this->level->getCollisionBlocks($bb->offset($x, 0.1, 0))) > 0) {
                     if ($isJump) {
                         $y = self::$jump;
                         $this->motionX = $x;
                     }
                     $x = 0;
                 }
                 //if ($y) echo "Jumping\n";
                 $ev = new \pocketmine\event\entity\EntityMotionEvent($this, new \pocketmine\math\Vector3($x, $y, $z));
                 $this->server->getPluginManager()->callEvent($ev);
                 if ($ev->isCancelled()) {
                     return false;
                 }
                 $this->x += $x;
                 $this->y += $y;
                 $this->z += $z;
             }
             if ($dist > 40) {
                 $target->sendMessage($this->petName_unformatted . " could not keep up - use /pet spawn again to bring them back");
                 $this->close();
             }
         }
     }
     $bb = clone $this->getBoundingBox();
     $onGround = count($this->level->getCollisionBlocks($bb->offset(0, -$this->gravity, 0))) > 0;
     $this->onGround = $onGround;
     $this->timings->stopTiming();
     $hasUpdate = parent::onUpdate($currentTick) || $hasUpdate;
     return $hasUpdate;
 }
开发者ID:flaxues,项目名称:BuddyPets,代码行数:96,代码来源:Pet.php


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