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 ff7b9b47c9c29949cc4ee8da162b77ef17909bdb..fa58ec5466edd5ce6a1887b73f628fb6c7272d88 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -228,7 +228,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 diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java index 3da3de6a442c3b398a96fff26cd0d81a8130fc01..02e8627fc9312e865f3a1f71cc9ecba712a098a2 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -200,6 +200,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, RegistryAccess iregistrycustom, 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.function.Function paperWorldConfigCreator) { // Paper diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java index e9ead1e49f9043430e316c36ade83b70cf850e47..f2d10d58617644a589ecec3e17358c1277795e5d 100644 --- a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java +++ b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java @@ -56,7 +56,7 @@ public class GameEventDispatcher { for (int l1 = j; l1 <= i1; ++l1) { for (int i2 = l; i2 <= k1; ++i2) { - LevelChunk chunk = this.level.getChunkSource().getChunkNow(l1, i2); + LevelChunk chunk = (LevelChunk) this.level.getChunkIfLoadedImmediately(l1, i2); // Paper if (chunk != null) { for (int j2 = k; j2 <= j1; ++j2) {