aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0591-Use-getChunkIfLoadedImmediately-in-places.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0591-Use-getChunkIfLoadedImmediately-in-places.patch')
-rw-r--r--patches/server/0591-Use-getChunkIfLoadedImmediately-in-places.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/patches/server/0591-Use-getChunkIfLoadedImmediately-in-places.patch b/patches/server/0591-Use-getChunkIfLoadedImmediately-in-places.patch
new file mode 100644
index 0000000000..19442f967b
--- /dev/null
+++ b/patches/server/0591-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 497dd11d7965c9f9a2cf991712cd30d875537240..49c23f4fbafbae516f3546c200448c400a6b0d5d 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 {
+ public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent
+
+ public LevelChunk getChunkIfLoaded(int x, int z) {
+- return this.chunkSource.getChunk(x, z, false);
++ return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
+ }
+
+ @Override
+diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
+index c4086b17db7624489a8873ee321e7707078e5e0b..9c8a2cae9832f2503aed6c2d6e32cdc2f12029c9 100644
+--- a/src/main/java/net/minecraft/world/level/Level.java
++++ b/src/main/java/net/minecraft/world/level/Level.java
+@@ -196,6 +196,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
+ return (CraftServer) Bukkit.getServer();
+ }
+
++ // Paper start - Use getChunkIfLoadedImmediately
++ @Override
++ public boolean hasChunk(int chunkX, int chunkZ) {
++ return this.getChunkIfLoaded(chunkX, chunkZ) != null;
++ }
++ // Paper end - Use getChunkIfLoadedImmediately
++
+ 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) { // Paper - create paper world config
+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 0d5ae91a9b43df7b412968ab5faf5498c09169f9..37ae0f928440af5b2fdfe68ad6c9c54e8c95c82c 100644
+--- a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java
++++ b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java
+@@ -55,7 +55,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 - Use getChunkIfLoadedImmediately
+
+ if (chunk != null) {
+ for (int j2 = k; j2 <= j1; ++j2) {