本文整理汇总了PHP中pocketmine\entity\Entity::getLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::getLevel方法的具体用法?PHP Entity::getLevel怎么用?PHP Entity::getLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\entity\Entity
的用法示例。
在下文中一共展示了Entity::getLevel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onRun
public function onRun($currentTick)
{
$explosion = new Explosion(new Position($this->entity->getX(), $this->entity->getY(), $this->entity->getZ(), $this->entity->getLevel()), $this->radius);
if (!$this->entity->isAlive()) {
return;
}
$this->entity->close();
if ($explosion->explodeA()) {
$explosion->explodeB();
}
}
示例2: 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));
}
示例3: __construct
public function __construct(Entity $target, $distance = 0, $tailCount = 0, $tailDistance = null)
{
parent::__construct($target->getLevel()->getChunk($target->x >> 4, $target->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $target->x), new Double("", $target->y + 0.5), new Double("", $target->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "TileID" => new Int("TileID", 1), "Data" => new Byte("Data", 0)]));
$this->target = $target;
$this->player = $target instanceof Player ? $target : ($target instanceof MobPetEntity && $target->player instanceof Player ? $target->player : null);
$this->distance = $target instanceof Player || $tailDistance == null ? $distance : $tailDistance;
if ($tailCount > 0) {
new MobPetEntity($this, $distance, $tailCount - 1, $tailDistance);
}
$this->isHead = $target instanceof Player;
parent::spawnToAll();
}
示例4: addEntity
/**
* @param Entity $entity
*
* @throws LevelException
*/
public function addEntity(Entity $entity)
{
if ($entity->getLevel() !== $this) {
throw new LevelException("Invalid Entity level");
}
if ($entity instanceof Player) {
$this->players[$entity->getId()] = $entity;
}
$this->entities[$entity->getId()] = $entity;
}
示例5: getCrosshairTarget
public static function getCrosshairTarget(Entity $entity, $accuracy = 0.5, $max = PHP_INT_MAX)
{
$found = null;
$direction = $entity->getDirectionVector()->multiply($accuracy);
/** @var Vector3 $last */
for ($last = null, $pos = $entity->add($direction), $i = 1; $i * $accuracy <= $max; $last = $pos->floor(), $pos = $entity->add($direction->multiply(++$i))) {
if ($last instanceof Vector3) {
if ($last->x === $pos->getFloorX() and $last->y === $pos->getFloorY() and $last->z === $pos->getFloorZ()) {
continue;
}
if ($pos->y < 0) {
break;
}
$maxY = 127;
if (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT")) {
$maxY = constant($path);
}
if ($pos->y > $maxY + 1) {
break;
}
$block = $entity->getLevel()->getBlock($pos);
if (!$block instanceof Block) {
break;
}
if ($block instanceof Air) {
continue;
}
$found = $block;
break;
}
}
return $found;
}
示例6: __construct
public function __construct(Entity $target)
{
parent::__construct($target->getLevel()->getChunk($target->x >> 4, $target->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $target->x), new Double("", $target->y + 0.5), new Double("", $target->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "TileID" => new Int("TileID", 1), "Data" => new Byte("Data", 0)]));
$this->item = Item::get(1, 0, 1);
$this->block = $target;
parent::spawnToAll();
}
示例7: checkSelectors
public function checkSelectors(array $args, CommandSender $sender, Entity $item)
{
foreach ($args as $name => $value) {
switch ($name) {
case "m":
$mode = intval($value);
if ($mode === -1) {
break;
}
// what is the point of adding this (in PC) when they can just safely leave this out?
if ($item instanceof Player && $mode !== $item->getGamemode()) {
return false;
}
break;
case "name":
if ($value[0] === "!") {
if (substr($value, 1) === strtolower($item->getName())) {
return false;
}
} else {
if ($value !== strtolower($item->getName())) {
return false;
}
}
break;
case "w":
// Non standard
if ($value[0] === "!") {
if (substr($value, 1) === strtolower($item->getLevel()->getName())) {
return false;
}
} else {
if ($value !== strtolower($item->getLevel()->getName())) {
return false;
}
}
break;
case "type":
if ($item instanceof Player) {
$type = "player";
} else {
$type = strtolower($item->getSaveId());
}
if ($value[0] === "!") {
if (substr($value, 1) === $type) {
return false;
}
} else {
if ($value !== $type) {
return false;
}
}
break;
// x,y,z
// r,rm
// c
// dx,dy,dz
// rx,rxm
// ry,rym
}
}
return true;
}
示例8: SoldierGame
public function SoldierGame(Entity $entity)
{
if ($this->checkEnableSoldierGame() and $entity->shootingEntity instanceof Player) {
$this->getServer()->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($entity, 2.5));
if (!$ev->isCancelled()) {
$entity->getLevel()->addParticle(new MobSpawnParticle($entity, 2, 2));
$explosion = new Explosion($entity, $ev->getForce(), $entity->shootingEntity);
$explosion->explodeB();
}
}
}
示例9: remove
public function remove(Entity $entity)
{
$entity->getLevel()->getServer()->getPluginManager()->callEvent($ev = new EntityEffectRemoveEvent($entity, $this));
if ($ev->isCancelled()) {
return;
}
if ($entity instanceof Player) {
$pk = new MobEffectPacket();
$pk->eid = 0;
$pk->eventId = MobEffectPacket::EVENT_REMOVE;
$pk->effectId = $this->getId();
$entity->dataPacket($pk);
}
if ($this->id === Effect::INVISIBILITY) {
$entity->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_INVISIBLE, false);
$entity->setNameTagVisible(true);
} elseif ($this->id === Effect::SPEED) {
$attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
$attr->setValue($attr->getValue() / (1 + 0.2 * $this->amplifier));
} elseif ($this->id === Effect::SLOWNESS) {
$attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
$attr->setValue($attr->getValue() / (1 - 0.15 * $this->amplifier));
}
}