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


PHP entity\Entity类代码示例

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


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

示例1: attackEntity

 public function attackEntity(Entity $player)
 {
     if ($this->attackDelay > 30 && mt_rand(1, 32) < 4 && $this->distanceSquared($player) <= 200) {
         $this->attackDelay = 0;
         $f = 2;
         $yaw = $this->yaw + mt_rand(-220, 220) / 10;
         $pitch = $this->pitch + mt_rand(-120, 120) / 10;
         $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x + -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2), new DoubleTag("", $this->y + 2), new DoubleTag("", $this->z + cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI)), new DoubleTag("", -sin($pitch / 180 * M_PI) * $f), new DoubleTag("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $yaw), new FloatTag("", $pitch)])]);
         $fireball = Entity::createEntity("FireBall", $this->chunk, $nbt, $this);
         if ($fireball instanceof FireBall) {
             $fireball->setExplode(true);
         }
         $fireball->setMotion($fireball->getMotion()->multiply($f));
         $ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $fireball, $f);
         $this->server->getPluginManager()->callEvent($ev);
         $projectile = $ev->getProjectile();
         if ($ev->isCancelled()) {
             $projectile->kill();
         } elseif ($projectile instanceof Projectile) {
             $this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
             if ($launch->isCancelled()) {
                 $projectile->kill();
             } else {
                 $projectile->spawnToAll();
                 $this->level->addSound(new LaunchSound($this), $this->getViewers());
             }
         }
     }
 }
开发者ID:steveritter,项目名称:EntityManager,代码行数:29,代码来源:Ghast.php

示例2: attackEntity

 public function attackEntity(Entity $player)
 {
     if ($this->attackDelay > 25 && mt_rand(1, 12) < 3 && $this->distanceSquared($player) <= 40) {
         $this->attackDelay = 0;
         $f = 1.5;
         $yaw = $this->yaw + mt_rand(-180, 180) / 10;
         $pitch = $this->pitch + mt_rand(-90, 90) / 10;
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y + 1.62), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * $f), new Double("", -sin($pitch / 180 * M_PI) * $f), new Double("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * $f)]), "Rotation" => new Enum("Rotation", [new Float("", $yaw), new Float("", $pitch)])]);
         /** @var Projectile $arrow */
         $arrow = Entity::createEntity("Arrow", $this->chunk, $nbt, $this);
         $ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $arrow, $f);
         $this->server->getPluginManager()->callEvent($ev);
         $projectile = $ev->getProjectile();
         if ($ev->isCancelled()) {
             $ev->getProjectile()->kill();
         } elseif ($projectile instanceof Projectile) {
             $this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
             if ($launch->isCancelled()) {
                 $projectile->kill();
             } else {
                 $projectile->spawnToAll();
                 $this->level->addSound(new LaunchSound($this), $this->getViewers());
             }
         }
     }
 }
开发者ID:rilex04,项目名称:EntityManager,代码行数:26,代码来源:Skeleton.php

示例3: onEntityCollide

 public function onEntityCollide(Entity $entity)
 {
     $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
     if ($entity->attack($ev->getFinalDamage(), $ev) === true) {
         $ev->useArmors();
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:7,代码来源:Cactus.php

示例4: canCollideWith

 public function canCollideWith(Entity $entity)
 {
     if ($entity instanceof Player) {
         return $entity instanceof Living && !$this->onGround && ($entity->getId() !== $this->getDataProperty(self::DATA_SHOOTER_ID) && ToAruPG::$pvpEnabled);
     }
     return $entity instanceof Living && !$this->onGround && $entity->getId() !== $this->getDataProperty(self::DATA_SHOOTER_ID);
 }
开发者ID:HelloWorld017,项目名称:ToAruArcher,代码行数:7,代码来源:EffectArrow.php

示例5: onEntityCollide

 public function onEntityCollide(Entity $entity)
 {
     if (abs($entity->motionY) < 0.1 && !$entity->isSneaking()) {
         (double) ($d0 = 0.4 + abs($entity->motionY) * 0.2);
         $entity->motionX *= $d0;
         $entity->motionZ *= $d0;
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:8,代码来源:Slimeblock.php

示例6: onEntityCollide

 public function onEntityCollide(Entity $entity)
 {
     $entity->resetFallDistance();
     if ($entity->fireTicks > 0) {
         $entity->extinguish();
     }
     $entity->resetFallDistance();
 }
开发者ID:xHFx,项目名称:ImagicalMine,代码行数:8,代码来源:Water.php

示例7: useOnEntity

 public function useOnEntity(Entity $entity, Entity $origin)
 {
     if ($entity instanceof Animal) {
         if ($entity->isLeashableType()) {
             $entity->setLeashHolder($origin);
         }
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:8,代码来源:Leash.php

示例8: addAttackerModifiers

 protected function addAttackerModifiers(Entity $damager)
 {
     if ($damager->hasEffect(Effect::STRENGTH)) {
         $this->setDamage($this->getDamage(self::MODIFIER_BASE) * 0.3 * ($damager->getEffect(Effect::STRENGTH)->getAmplifier() + 1), self::MODIFIER_STRENGTH);
     }
     if ($damager->hasEffect(Effect::WEAKNESS)) {
         $this->setDamage(-($this->getDamage(self::MODIFIER_BASE) * 0.2 * ($damager->getEffect(Effect::WEAKNESS)->getAmplifier() + 1)), self::MODIFIER_WEAKNESS);
     }
 }
开发者ID:worlds1,项目名称:NIGHTMARE,代码行数:9,代码来源:EntityDamageByEntityEvent.php

示例9: onEntityCollide

 public function onEntityCollide(Entity $entity)
 {
     $entity->setOnFire(8);
     $ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_FIRE, 1);
     Server::getInstance()->getPluginManager()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $entity->attack($ev->getFinalDamage(), $ev);
     }
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:9,代码来源:Fire.php

示例10: onEntityCollide

 public function onEntityCollide(Entity $entity)
 {
     $entity->fallDistance = 0;
     if ($entity->fireTicks > 0) {
         $entity->extinguish();
     }
     if ($entity instanceof Player) {
         $entity->onGround = true;
     }
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:10,代码来源:Water.php

示例11: onEntityCollide

 public function onEntityCollide(Entity $entity)
 {
     if (!$entity->hasEffect(Effect::FIRE_RESISTANCE)) {
         $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
         $entity->attack($ev->getFinalDamage(), $ev);
     }
     $ev = new EntityCombustByBlockEvent($this, $entity, 8);
     Server::getInstance()->getPluginManager()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $entity->setOnFire($ev->getDuration());
     }
 }
开发者ID:orlando092,项目名称:ImagicalMine,代码行数:12,代码来源:Fire.php

示例12: useOn

 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  *
  * @return bool
  */
 public function useOn($object)
 {
     if ($this->isHoe()) {
         if ($object instanceof Block and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)) {
             $this->meta++;
         }
     } elseif ($object instanceof Entity and !$this->isSword()) {
         $this->meta += 2;
     } else {
         $this->meta++;
     }
     return true;
 }
开发者ID:mattiasaxelsson,项目名称:PocketMine-MP,代码行数:20,代码来源:Tool.php

示例13: addAttackerModifiers

 protected function addAttackerModifiers(Entity $damager)
 {
     if ($damager->hasEffect(Effect::STRENGTH)) {
         $this->setRateDamage(1 + 0.3 * ($damager->getEffect(Effect::STRENGTH)->getAmplifier() + 1), self::MODIFIER_STRENGTH);
     }
     if ($damager->hasEffect(Effect::WEAKNESS)) {
         $eff_level = 1 - 0.2 * ($damager->getEffect(Effect::WEAKNESS)->getAmplifier() + 1);
         if ($eff_level < 0) {
             $eff_level = 0;
         }
         $this->setRateDamage($eff_level, self::MODIFIER_WEAKNESS);
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:13,代码来源:EntityDamageByEntityEvent.php

示例14: useOn

 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  * @param 1 for break|2 for Touch $type
  *
  * @return bool
  */
 public function useOn($object, $type = 1)
 {
     if ($this->isUnbreakable()) {
         return true;
     }
     $unbreakingl = $this->getEnchantmentLevel(Enchantment::TYPE_MINING_DURABILITY);
     $unbreakingl = $unbreakingl > 3 ? 3 : $unbreakingl;
     if (mt_rand(1, $unbreakingl + 1) !== 1) {
         return true;
     }
     if ($type === 1) {
         if ($object instanceof Entity) {
             if ($this->isHoe() !== false or $this->isSword() !== false) {
                 //Hoe and Sword
                 $this->meta++;
                 return true;
             } elseif ($this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false) {
                 //Pickaxe Axe and Shovel
                 $this->meta += 2;
                 return true;
             }
             return true;
             //Other tool do not lost durability white hitting
         } elseif ($object instanceof Block) {
             if ($this->isShears() !== false) {
                 if ($object->getToolType() === Tool::TYPE_SHEARS) {
                     //This should be checked in each block
                     $this->meta++;
                 }
                 return true;
             } elseif ($object->getHardness() > 0) {
                 //Sword Pickaxe Axe and Shovel
                 if ($this->isSword() !== false) {
                     $this->meta += 2;
                     return true;
                 } elseif ($this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false) {
                     $this->meta += 1;
                     return true;
                 }
             }
         }
     } elseif ($type === 2) {
         //For Touch. only trigger when OnActivate return true
         if ($this->isHoe() !== false or $this->id === self::FLINT_STEEL or $this->isShovel() !== false) {
             $this->meta++;
             return true;
         }
     }
     return true;
 }
开发者ID:AnonymousProjects,项目名称:PocketMine-MP-Original,代码行数:58,代码来源:Tool.php

示例15: onEntityCollide

 public function onEntityCollide(Entity $entity)
 {
     $entity->fallDistance *= 0.5;
     $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
     $entity->attack($ev->getFinalDamage(), $ev);
     $ev = new EntityCombustByBlockEvent($this, $entity, 15);
     Server::getInstance()->getPluginManager()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $entity->setOnFire($ev->getDuration());
     }
     if ($entity instanceof Player) {
         $entity->onGround = true;
     }
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:14,代码来源:Lava.php


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