aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0675-Use-getChunkIfLoadedImmediately-in-places.patch
blob: 1e0ae5d1ce50f603c5d74442cf6d61a1b85696ba (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
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 6e9f1f01227a94480043ba3120c77f1ae080ec02..d0c4c9c172c8caa3eaf6c0bf56a8be9f16d8c4e7 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -223,7 +223,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
@@ -1441,7 +1441,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 ea2e75b227673f8b0016254f8c52a6721c8adf33..4b7ed29a7a38cf7f8fb488c9c34471fafcdf2f25 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -199,6 +199,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, 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