diff --git a/src/entity/Entity.php b/src/entity/Entity.php index bdd7b79f6..b55c4a008 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -77,6 +77,16 @@ abstract class Entity{ public const MOTION_THRESHOLD = 0.00001; + /** @var int */ + private static $entityCount = 1; + + /** + * Returns a new runtime entity ID for a new entity. + */ + public static function nextRuntimeId() : int{ + return self::$entityCount++; + } + /** @var Player[] */ protected $hasSpawned = []; @@ -221,7 +231,7 @@ abstract class Entity{ $this->eyeHeight = $this->height / 2 + 0.1; } - $this->id = EntityFactory::nextRuntimeId(); + $this->id = self::nextRuntimeId(); $this->server = $location->getWorldNonNull()->getServer(); $this->location = $location->asLocation(); diff --git a/src/entity/EntityFactory.php b/src/entity/EntityFactory.php index a4d9fbfe6..97d3cfedd 100644 --- a/src/entity/EntityFactory.php +++ b/src/entity/EntityFactory.php @@ -65,9 +65,6 @@ use function reset; final class EntityFactory{ use SingletonTrait; - /** @var int */ - private static $entityCount = 1; - /** * @var \Closure[] base class => creator function * @phpstan-var array, \Closure(World, CompoundTag) : Entity> @@ -223,13 +220,6 @@ final class EntityFactory{ $this->saveNames[$className] = $saveNames; } - /** - * Returns a new runtime entity ID for a new entity. - */ - public static function nextRuntimeId() : int{ - return self::$entityCount++; - } - /** * Creates an entity from data stored on a chunk. * diff --git a/src/world/particle/FloatingTextParticle.php b/src/world/particle/FloatingTextParticle.php index 5a99f9df0..5b787580a 100644 --- a/src/world/particle/FloatingTextParticle.php +++ b/src/world/particle/FloatingTextParticle.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace pocketmine\world\particle; -use pocketmine\entity\EntityFactory; +use pocketmine\entity\Entity; use pocketmine\entity\Skin; use pocketmine\math\Vector3; use pocketmine\network\mcpe\convert\SkinAdapterSingleton; @@ -84,7 +84,7 @@ class FloatingTextParticle implements Particle{ $p = []; if($this->entityId === null){ - $this->entityId = EntityFactory::nextRuntimeId(); + $this->entityId = Entity::nextRuntimeId(); }else{ $p[] = RemoveActorPacket::create($this->entityId); }