mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-23 16:41:35 +01:00
Auto load chunk when spawning entities
This commit is contained in:
parent
9893bb72c8
commit
95eddf47de
@ -880,9 +880,11 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
}
|
||||
});
|
||||
|
||||
final Chunk chunk = getChunkAt(entityPosition);
|
||||
Check.notNull(chunk, "You tried to spawn an entity in an unloaded chunk, " + entityPosition);
|
||||
addEntityToChunk(entity, chunk);
|
||||
// Load the chunk if not already (or throw an error if auto chunk load is disabled)
|
||||
loadOptionalChunk(entityPosition, chunk -> {
|
||||
Check.notNull(chunk, "You tried to spawn an entity in an unloaded chunk, " + entityPosition);
|
||||
addEntityToChunk(entity, chunk);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user