mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 23:17:59 +02:00
Remove unnecessary condition, prevent double chunk refresh
This commit is contained in:
parent
effca76196
commit
c960bb297b
@ -1270,18 +1270,13 @@ public class Entity implements Viewable, EventHandler, DataContainer, Permission
|
|||||||
|
|
||||||
final Instance instance = getInstance();
|
final Instance instance = getInstance();
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
|
|
||||||
// Needed to refresh the client chunks when connecting for the first time
|
|
||||||
final boolean forceUpdate = this instanceof Player && ((Player) this).getViewableChunks().isEmpty();
|
|
||||||
|
|
||||||
final Chunk lastChunk = instance.getChunkAt(lastX, lastZ);
|
final Chunk lastChunk = instance.getChunkAt(lastX, lastZ);
|
||||||
final Chunk newChunk = instance.getChunkAt(x, z);
|
final Chunk newChunk = instance.getChunkAt(x, z);
|
||||||
|
|
||||||
Check.notNull(lastChunk, "The entity " + getEntityId() + " was in an unloaded chunk at " + lastX + ";" + lastZ);
|
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);
|
Check.notNull(newChunk, "The entity " + getEntityId() + " tried to move in an unloaded chunk at " + x + ";" + z);
|
||||||
|
|
||||||
final boolean chunkChange = lastChunk != newChunk;
|
if (lastChunk != newChunk) {
|
||||||
if (forceUpdate || chunkChange) {
|
|
||||||
instance.switchEntityChunk(this, lastChunk, newChunk);
|
instance.switchEntityChunk(this, lastChunk, newChunk);
|
||||||
if (this instanceof Player) {
|
if (this instanceof Player) {
|
||||||
// Refresh player view
|
// Refresh player view
|
||||||
|
Loading…
Reference in New Issue
Block a user