aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0555-Use-getChunkIfLoadedImmediately-in-places.patch
blob: a5b4d06295df27e96df02a09bdde60ac3c907c93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
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 1be314ed35d07e6db9a3f6a4f493b0f4bb59a45f..d8f7d7512db9432f67b07e7d64a6a9349dfab245 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -234,7 +234,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
     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 aff89d2e3274b91238989fc1e7d8c119c2a3c097..560777a99b58c4f82cc0e8fb087de04a564163b5 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -180,6 +180,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
     public CraftServer getCraftServer() {
         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();
 
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 13b34e89bd3e55df1bb1d4d0cf013bafae43f502..df6c97be1b278c97a20390be5d3e60f429383702 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 - Use getChunkIfLoadedImmediately
 
                 if (chunk != null) {
                     for (int j2 = k; j2 <= j1; ++j2) {