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


PHP Entity::getId方法代码示例

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


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

示例1: 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

示例2: 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

示例3: useOn

 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  *
  * @return bool
  */
 public function useOn($object)
 {
     if ($this->isUnbreakable()) {
         return false;
     }
     $break = true;
     if (($ench = $this->getEnchantment(Enchantment::TYPE_MINING_DURABILITY)) != null) {
         $rnd = mt_rand(1, 100);
         if ($rnd <= 100 / ($ench->getLevel() + 1)) {
             $break = false;
         }
     }
     if ($object instanceof Block) {
         if (!$break) {
             return false;
         }
         if ($object->getToolType() === Tool::TYPE_PICKAXE and $this->isPickaxe() or $object->getToolType() === Tool::TYPE_SHOVEL and $this->isShovel() or $object->getToolType() === Tool::TYPE_AXE and $this->isAxe() or $object->getToolType() === Tool::TYPE_SWORD and $this->isSword() or $object->getToolType() === Tool::TYPE_SHEARS and $this->isShears()) {
             $this->meta++;
         } elseif (!$this->isShears() and $object->getBreakTime($this) > 0) {
             $this->meta += 2;
         }
     } elseif ($this->isHoe()) {
         if (!$break) {
             return false;
         }
         if ($object instanceof Block and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)) {
             $this->meta++;
         }
     } elseif ($object instanceof Entity) {
         $return = true;
         if (!$this->isSword()) {
             if ($break) {
                 $this->meta += 2;
                 $return = false;
             }
         } else {
             if ($break) {
                 $this->meta++;
                 $return = false;
             }
             if (!$this->hasEnchantments()) {
                 return $return;
             }
             //TODO: move attacking from player class here
             //$fire = $this->getEnchantment(Enchantment::TYPE_WEAPON_FIRE_ASPECT);
             //$object->setOnFire($fire->getLevel() * 4);
         }
     }
     return true;
 }
开发者ID:Cecil107,项目名称:PocketMine-0.13.0,代码行数:57,代码来源:Tool.php

示例4: sendEntityInfo

 /**
  * @param CommandSender $sender
  * @param Entity $entity
  */
 public function sendEntityInfo(CommandSender $sender, Entity $entity)
 {
     $sender->sendMessage("Nametag: " . $entity->getNameTag());
     $sender->sendMessage("Health: " . $entity->getHealth() . "/" . $entity->getMaxHealth());
     $sender->sendMessage("XYZ: " . $entity->getFloorX() . ":" . $entity->getFloorY() . ":" . $entity->getFloorZ());
     $sender->sendMessage("Level: " . $entity->getLevel()->getName());
     $sender->sendMessage("Id: " . $entity->getId());
     $sender->sendMessage("Save-id: " . $entity->getSaveId());
     $sender->sendMessage("Last-damage-cause: " . ($entity->getLastDamageCause() !== null ? TextFormat::GREEN . $entity->getLastDamageCause()->getCause() : TextFormat::RED . "none"));
     $sender->sendMessage("Eye-height" . $entity->getEyeHeight());
     $sender->sendMessage("Is-alive: " . ($entity->isAlive() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-nametag-visible: " . ($entity->isNameTagVisible() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-inside-water: " . ($entity->isInsideOfWater() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-inside-solid: " . ($entity->isInsideOfSolid() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-on-ground: " . ($entity->isOnGround() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-on-fire: " . ($entity->isOnFire() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     //$sender->sendMessage("Is-sneaking: ".($entity->isSneaking() ? TextFormat::GREEN."yes" : TextFormat::RED."no"));
     //$sender->sendMessage("Is-sprinting: ".($entity->isSprinting() ? TextFormat::GREEN."yes" : TextFormat::RED."no"));
     $effectCount = 0;
     $effectNames = "";
     foreach ($entity->getEffects() as $effect) {
         $effectNames .= $effect->getName() . ", ";
         $effectCount++;
     }
     $sender->sendMessage("Effects (" . $effectCount . "): " . substr($effectNames, 0, -2));
     $viewerCount = 0;
     $viewerNames = "";
     foreach ($entity->getViewers() as $viewer) {
         $viewerNames .= $viewer->getName() . ", ";
         $viewerCount++;
     }
     $sender->sendMessage("Viewers (" . $viewerCount . "): " . substr($viewerNames, 0, -2));
 }
开发者ID:happyexceed,项目名称:PocketMine-Plugins-1,代码行数:37,代码来源:InfoFetcher.php

示例5: __construct

 public function __construct(FullChunk $chunk, Compound $nbt, Entity $shootingEntity = null)
 {
     $this->shootingEntity = $shootingEntity;
     if ($shootingEntity !== null) {
         $this->setDataProperty(self::DATA_SHOOTER_ID, self::DATA_TYPE_LONG, $shootingEntity->getId());
     }
     parent::__construct($chunk, $nbt);
 }
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:8,代码来源:Projectile.php

示例6: useOn

 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  *
  * @return bool
  */
 public function useOn($object)
 {
     if ($this->isUnbreakable()) {
         return true;
     }
     if ($object instanceof Block) {
         if ($object->getToolType() === Tool::TYPE_PICKAXE and $this->isPickaxe() or $object->getToolType() === Tool::TYPE_SHOVEL and $this->isShovel() or $object->getToolType() === Tool::TYPE_AXE and $this->isAxe() or $object->getToolType() === Tool::TYPE_SWORD and $this->isSword() or $object->getToolType() === Tool::TYPE_SHEARS and $this->isShears()) {
             $this->meta++;
         } elseif (!$this->isShears() and $object->getBreakTime($this) > 0) {
             $this->meta += 2;
         }
     } elseif ($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:ianju,项目名称:PocketMine-MP,代码行数:29,代码来源:Tool.php

示例7: onConsume

 public function onConsume(Entity $human)
 {
     $pk = new EntityEventPacket();
     $pk->eid = $human->getId();
     $pk->event = EntityEventPacket::USE_ITEM;
     if ($human instanceof Player) {
         $human->dataPacket($pk);
     }
     Server::broadcastPacket($human->getViewers(), $pk);
     $ev = new EntityEatItemEvent($human, $this);
     $human->addSaturation($ev->getSaturationRestore());
     $human->addFood($ev->getFoodRestore());
     foreach ($ev->getAdditionalEffects() as $effect) {
         $human->addEffect($effect);
     }
     $human->getInventory()->setItemInHand($ev->getResidue());
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:17,代码来源:Food.php

示例8: knockBackover

 public function knockBackover(Entity $entity, Vector3 $v3)
 {
     if ($entity instanceof Entity) {
         if (isset($this->zombie[$entity->getId()])) {
             $entity->setPosition($v3);
             $this->zombie[$entity->getId()]['knockBack'] = false;
         }
         if (isset($this->Cow[$entity->getId()])) {
             $entity->setPosition($v3);
             $this->Cow[$entity->getId()]['knockBack'] = false;
         }
         if (isset($this->Pig[$entity->getId()])) {
             $entity->setPosition($v3);
             $this->Pig[$entity->getId()]['knockBack'] = false;
         }
         if (isset($this->Sheep[$entity->getId()])) {
             $entity->setPosition($v3);
             $this->Sheep[$entity->getId()]['knockBack'] = false;
         }
         if (isset($this->Chicken[$entity->getId()])) {
             $entity->setPosition($v3);
             $this->Chicken[$entity->getId()]['knockBack'] = false;
         }
         if (isset($this->Skeleton[$entity->getId()])) {
             $entity->setPosition($v3);
             $this->Skeleton[$entity->getId()]['knockBack'] = false;
         }
         if (isset($this->Creeper[$entity->getId()])) {
             $entity->setPosition($v3);
             $this->Creeper[$entity->getId()]['knockBack'] = false;
         }
     }
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:33,代码来源:AIHolder.php

示例9: unlinkEntity

 public function unlinkEntity(Entity $entity)
 {
     if ($this->linkedTarget instanceof Entity) {
         $this->linkedTarget = null;
         $entity->islinked = false;
     }
     $pk = new SetEntityLinkPacket();
     $pk->from = $entity->getId();
     $pk->to = 0;
     $pk->type = 0;
     $this->dataPacket($pk);
     $this->islinked = false;
 }
开发者ID:Cecil107,项目名称:PocketMine-0.13.0,代码行数:13,代码来源:Entity.php

示例10: removeEntity

 public function removeEntity(Entity $entity)
 {
     unset($this->entities[$entity->getId()]);
     if (!$entity instanceof Player and $this->isInit) {
         $this->hasChanged = \true;
     }
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:7,代码来源:BaseFullChunk.php

示例11: removeEntity

 public function removeEntity(Entity $entity)
 {
     unset($this->entities[$entity->getId()]);
     $this->hasChanged = true;
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:5,代码来源:BaseFullChunk.php

示例12: onConsume

 public function onConsume(Entity $human)
 {
     $pk = new EntityEventPacket();
     $pk->eid = $human->getId();
     $pk->event = EntityEventPacket::USE_ITEM;
     if ($human instanceof Player) {
         $human->dataPacket($pk);
     }
     Server::broadcastPacket($human->getViewers(), $pk);
     Server::getInstance()->getPluginManager()->callEvent($ev = new EntityDrinkPotionEvent($human, $this));
     if (!$ev->isCancelled()) {
         foreach ($ev->getEffects() as $effect) {
             $human->addEffect($effect);
         }
         //Don't set the held item to glass bottle if we're in creative
         if ($human instanceof Player) {
             if ($human->getGamemode() === 1) {
                 return;
             }
         }
         $human->getInventory()->setItemInHand(Item::get(self::GLASS_BOTTLE));
     }
 }
开发者ID:kniffo80,项目名称:Genisys,代码行数:23,代码来源:Potion.php

示例13: linkEntity

 public function linkEntity(Entity $entity = null)
 {
     if ($entity !== null and $entity->getlinkType() == Entity::LINK_EMPTY and $entity->isAlive()) {
         $this->linkedTarget = $entity;
         $this->islinked = true;
         $entity->islinked = true;
         $pk = new SetEntityLinkPacket();
         $pk->from = $entity->getId();
         $pk->to = $this->getId();
         $pk->type = 1;
         $this->server->broadcastPacket($this->level->getPlayers(), $pk);
         if ($this instanceof Player) {
             $pk = new SetEntityLinkPacket();
             $pk->from = $entity->getId();
             $pk->to = 0;
             $pk->type = 1;
             $this->dataPacket($pk);
         }
     }
     return false;
 }
开发者ID:MCSou,项目名称:ClearSky,代码行数:21,代码来源:Entity.php

示例14: setLinked

 public function setLinked($type = 0, Entity $entity = null)
 {
     if ($type != 0 and $entity === null) {
         return false;
     }
     if ($entity === $this) {
         return false;
     }
     switch ($type) {
         case 0:
             if ($this->linkedType == 0) {
                 return true;
             }
             $this->linkedType = 0;
             $pk = new SetEntityLinkPacket();
             $pk->from = $entity->getId();
             $pk->to = $this->getId();
             $pk->type = 3;
             $this->server->broadcastPacket($this->level->getPlayers(), $pk);
             if ($this instanceof Player) {
                 $pk = new SetEntityLinkPacket();
                 $pk->from = $entity->getId();
                 $pk->to = 0;
                 $pk->type = 3;
                 $this->dataPacket($pk);
             }
             if ($this->linkedEntity->getLinkedType()) {
                 $this->linkedEntity->setLinked(0, $this);
             }
             return true;
         case 1:
             if (!$entity->isAlive()) {
                 return false;
             }
             $this->linkedEntity = $entity;
             $this->linkedType = 1;
             $pk = new SetEntityLinkPacket();
             $pk->from = $entity->getId();
             $pk->to = $this->getId();
             $pk->type = 2;
             $this->server->broadcastPacket($this->level->getPlayers(), $pk);
             if ($this instanceof Player) {
                 $pk = new SetEntityLinkPacket();
                 $pk->from = $entity->getId();
                 $pk->to = 0;
                 $pk->type = 2;
                 $this->dataPacket($pk);
             }
             return true;
         case 2:
             if (!$entity->isAlive()) {
                 return false;
             }
             if ($entity->getLinkedEntity() !== $this) {
                 return $entity->linkEntity($this);
             }
             $this->linkedEntity = $entity;
             $this->linkedType = 2;
             return true;
         default:
             return false;
     }
 }
开发者ID:robske110,项目名称:ImagicalMine,代码行数:63,代码来源:Entity.php

示例15: remove

 public function remove(Entity $entity)
 {
     if ($entity instanceof Player) {
         $pk = new MobEffectPacket();
         $pk->eid = $entity->getId();
         $pk->eventId = MobEffectPacket::EVENT_REMOVE;
         $pk->effectId = $this->getId();
         $entity->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
     }
     if ($this->id === Effect::INVISIBILITY) {
         $entity->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_INVISIBLE, false);
         $entity->setDataProperty(Entity::DATA_SHOW_NAMETAG, Entity::DATA_TYPE_BYTE, 1);
     }
 }
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:14,代码来源:Effect.php


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