summaryrefslogtreecommitdiffhomepage
path: root/patches/unapplied/server/0648-Use-getChunkIfLoadedImmediately-in-places.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/unapplied/server/0648-Use-getChunkIfLoadedImmediately-in-places.patch')
-rw-r--r--patches/unapplied/server/0648-Use-getChunkIfLoadedImmediately-in-places.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/patches/unapplied/server/0648-Use-getChunkIfLoadedImmediately-in-places.patch b/patches/unapplied/server/0648-Use-getChunkIfLoadedImmediately-in-places.patch
new file mode 100644
index 0000000000..0e843b1ab5
--- /dev/null
+++ b/patches/unapplied/server/0648-Use-getChunkIfLoadedImmediately-in-places.patch
@@ -0,0 +1,53 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Spottedleaf <[email protected]>
+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 e93a1713505d52d719738b36ea59859c547553b7..16b73f0498936a8413f6adedd7f92bab07a4a108 100644
+--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
+@@ -225,7 +225,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 8a6f01af6d9a210fbd5cf14002c426c2e36fc51b..5f43dbd3b4a50f425b188beb2ed9236ed2db0a06 100644
+--- a/src/main/java/net/minecraft/world/level/Level.java
++++ b/src/main/java/net/minecraft/world/level/Level.java
+@@ -202,6 +202,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<LevelStem> getTypeKey();
+
+ protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> 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<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor
+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 cd92aaa1c874d78762bbab529dfcea71b36d2a91..25e4596e64b74ada86f210b06ba837be8efc21d1 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) {