mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-02 11:21:15 +01:00
Fixed error with unloaded chunks
This commit is contained in:
parent
3c64def9f9
commit
2b529e05d0
@ -339,8 +339,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean chunkUnloaded = !ChunkUtils.isLoaded(instance, position.getX(), position.getZ());
|
||||
if (chunkUnloaded) {
|
||||
if (!ChunkUtils.isLoaded(instance, position.getX(), position.getZ())) {
|
||||
// No update for entities in unloaded chunk
|
||||
return;
|
||||
}
|
||||
@ -392,6 +391,11 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
|
||||
);
|
||||
onGround = CollisionUtils.handlePhysics(this, deltaPos, newPosition, newVelocityOut);
|
||||
|
||||
// Check chunk
|
||||
if (!ChunkUtils.isLoaded(instance, newPosition.getX(), newPosition.getZ())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// World border collision
|
||||
{
|
||||
final WorldBorder worldBorder = instance.getWorldBorder();
|
||||
@ -461,10 +465,11 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
chunkUnloaded = !ChunkUtils.isLoaded(instance, x, z);
|
||||
if (chunkUnloaded)
|
||||
final Chunk chunk = instance.getChunkAt(x, z);
|
||||
if (!ChunkUtils.isLoaded(chunk))
|
||||
continue;
|
||||
final CustomBlock customBlock = instance.getCustomBlock(x, y, z);
|
||||
|
||||
final CustomBlock customBlock = chunk.getCustomBlock(x, y, z);
|
||||
if (customBlock != null) {
|
||||
tmpPosition.setX(x);
|
||||
tmpPosition.setY(y);
|
||||
|
@ -650,7 +650,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
* @param z the Z position
|
||||
* @return the chunk at the given position, null if not loaded
|
||||
*/
|
||||
public Chunk getChunkAt(double x, double z) {
|
||||
public Chunk getChunkAt(float x, float z) {
|
||||
final int chunkX = ChunkUtils.getChunkCoordinate((int) x);
|
||||
final int chunkZ = ChunkUtils.getChunkCoordinate((int) z);
|
||||
return getChunk(chunkX, chunkZ);
|
||||
|
Loading…
Reference in New Issue
Block a user