public function isAlive() { if ($this->entity !== null) { return $this->entity->isAlive(); } return false; }
/** * 움직이는 플레이어 엔티티를 생성합니다. * * @param int|string $type * @param Position $source * @param mixed ...$args * * @return BaseEntity|Entity */ public static function createEntity(DummyReceiver $receiver, Position $source, ...$args) { $chunk = $source->getLevel()->getChunk($source->x >> 4, $source->z >> 4, true); if ($chunk == null) { return null; } if (!$chunk->isLoaded()) { $chunk->load(); } if (!$chunk->isGenerated()) { $chunk->setGenerated(); } if (!$chunk->isPopulated()) { $chunk->setPopulated(); } $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $source->x), new DoubleTag("", $source->y), new DoubleTag("", $source->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $source instanceof Location ? $source->yaw : 0), new FloatTag("", $source instanceof Location ? $source->pitch : 0)])]); /** @var BaseEntity $entity */ $entity = new DummyEntity($chunk, $nbt, ...$args); if ($entity != null && $entity->isCreated()) { $entity->spawnToAll(); } return $entity; }