mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-27 14:13:24 +02:00
Throw an exception when an entity tries to move in an unloaded chunk
This commit is contained in:
parent
44096ff9cf
commit
77b4fe7287
@ -1079,9 +1079,11 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
||||
final Chunk lastChunk = instance.getChunkAt(lastX, lastZ);
|
||||
final Chunk newChunk = instance.getChunkAt(x, z);
|
||||
|
||||
final boolean chunkExist = lastChunk != null && newChunk != null;
|
||||
Check.notNull(lastChunk, "The entity " + getEntityId() + " was in an unloaded chunk at " + lastX + ";" + lastZ);
|
||||
Check.notNull(newChunk, "The entity " + getEntityId() + " tried to move in an unloaded chunk at " + x + ";" + z);
|
||||
|
||||
final boolean chunkChange = lastChunk != newChunk;
|
||||
if (chunkExist && (forceUpdate || chunkChange)) {
|
||||
if (forceUpdate || chunkChange) {
|
||||
instance.switchEntityChunk(this, lastChunk, newChunk);
|
||||
if (this instanceof Player) {
|
||||
// Refresh player view
|
||||
|
Loading…
Reference in New Issue
Block a user