diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 73a0b3a9c..89f66d6b1 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -492,7 +492,7 @@ abstract class Entity{ new FloatTag($this->location->pitch) ])); - if(!($this instanceof Player)){ + if(!($this instanceof NeverSavedWithChunkEntity)){ EntityFactory::getInstance()->injectSaveId(get_class($this), $nbt); if($this->getNameTag() !== ""){ diff --git a/src/entity/NeverSavedWithChunkEntity.php b/src/entity/NeverSavedWithChunkEntity.php new file mode 100644 index 000000000..2245abdd9 --- /dev/null +++ b/src/entity/NeverSavedWithChunkEntity.php @@ -0,0 +1,36 @@ +getId()); } } - if(!EntityFactory::getInstance()->isRegistered($entity::class) && !$entity instanceof Player){ + if(!EntityFactory::getInstance()->isRegistered($entity::class) && !$entity instanceof NeverSavedWithChunkEntity){ //canSaveWithChunk is mutable, so that means it could be toggled after adding the entity and cause a crash //later on. Better we just force all entities to have a save ID, even if it might not be needed. throw new \LogicException("Entity " . $entity::class . " is not registered for a save ID in EntityFactory");