mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 08:20:51 +01:00
1e7dd72f15
The game uses 0.95d now
54 lines
3.2 KiB
Diff
54 lines
3.2 KiB
Diff
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 08fee3d75a9f7ae950698a6ca8f18917ab0e3b21..107e2b2a159838301e173323df1747954a52b104 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -230,7 +230,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 befd147f604bf9cf881893580436bbf8fbead86d..031fe212e5bc28ac675f835bec37c1bca3c5351f 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -204,6 +204,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 0d5ae91a9b43df7b412968ab5faf5498c09169f9..744160405680babbb83c99abcbe2dc89bf312398 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
|
|
|
|
if (chunk != null) {
|
|
for (int j2 = k; j2 <= j1; ++j2) {
|