Fix crash when a player is added to the world

This commit is contained in:
Dylan K. Taylor 2025-04-26 22:11:03 +01:00
parent cfafb584a8
commit fe70b31881
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -2778,7 +2778,7 @@ class World implements ChunkManager{
throw new AssumptionFailedError("Found two different entities sharing entity ID " . $entity->getId());
}
}
if(!EntityFactory::getInstance()->isRegistered($entity::class)){
if(!EntityFactory::getInstance()->isRegistered($entity::class) && !$entity instanceof Player){
//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");