From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 8 Jul 2019 00:13:36 -0700 Subject: [PATCH] Use getChunkIfLoadedImmediately in places This prevents us from hitting chunk loads for chunks at or less-than ticket level 33 (yes getChunkIfLoaded will actually perform a chunk load in that case). diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index e0a5e978d584bcc0e692806b3d80d01710526eb3..62bb1fd46e4dff43e9c83c05260c7deaffe445a9 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -220,7 +220,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } @Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI - return this.chunkSource.getChunk(x, z, false); + return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper } @Override @@ -1433,7 +1433,7 @@ public class ServerLevel extends Level implements WorldGenLevel { for (int l1 = j; l1 <= i1; ++l1) { for (int i2 = l; i2 <= k1; ++i2) { - LevelChunk chunk = this.getChunkSource().getChunkNow(l1, i2); + LevelChunk chunk = (LevelChunk) this.getChunkIfLoadedImmediately(l1, i2); // Paper if (chunk != null) { for (int j2 = k; j2 <= j1; ++j2) { diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java index 474b1dc68e138fb3fcca8c846d50fa2c04f74fd5..7a378def3702bc3e2fd20d422ec38e20d4083574 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -195,6 +195,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return (CraftServer) Bukkit.getServer(); } + // Paper start + @Override + public boolean hasChunk(int chunkX, int chunkZ) { + return this.getChunkIfLoaded(chunkX, chunkZ) != null; + } + // Paper end + public abstract ResourceKey getTypeKey(); protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor