#673: Fix Craftworld#isChunkLoaded

The flag for getChunkAt(int, int, ChunkStatus, boolean)
is actually a flag for whether to bring the underlying
PlayerChunk up to the required ticket level to load the
chunk. So, if the chunk is already at the required level,
but has not yet loaded, the call will actually either
start the load if it has not already been started and
block until completion.

This behaviour is not suitable for just
checking if the chunk is loaded.

By: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
CraftBukkit/Spigot
2020-06-06 19:23:46 +10:00
parent 3be59d8d05
commit ecdda0bdbc
2 changed files with 30 additions and 15 deletions

View File

@@ -340,8 +340,7 @@ public class CraftWorld implements World {
@Override
public boolean isChunkLoaded(int x, int z) {
net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAt(x, z, false);
return chunk != null;
return world.getChunkProvider().isChunkLoaded(x, z);
}
@Override
@@ -381,19 +380,18 @@ public class CraftWorld implements World {
@Override
public boolean unloadChunkRequest(int x, int z) {
net.minecraft.server.IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, false);
if (chunk != null) {
world.getChunkProvider().removeTicket(TicketType.PLUGIN, chunk.getPos(), 1, Unit.INSTANCE);
if (isChunkLoaded(x, z)) {
world.getChunkProvider().removeTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE);
}
return true;
}
private boolean unloadChunk0(int x, int z, boolean save) {
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, false);
if (chunk == null) {
if (!isChunkLoaded(x, z)) {
return true;
}
net.minecraft.server.Chunk chunk = world.getChunkAt(x, z);
chunk.mustNotSave = !save;
unloadChunkRequest(x, z);