2021-07-02 19:04:29 +00:00
|
|
|
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
|
2022-03-01 05:43:03 +00:00
|
|
|
index 3fac2eba419cfa41c80ea461964ec8963bcd91ab..3f912338b9fc5ec85a9d6748df6dbe490d08dbcf 100644
|
2021-07-02 19:04:29 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -215,7 +215,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
2021-07-02 19:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
|
}
|
|
|
|
|
2021-11-24 23:26:29 +00:00
|
|
|
@Override
|
2021-07-02 19:04:29 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2022-03-01 05:43:03 +00:00
|
|
|
index c52b292f4fe13a3fa586caa6452016bf0937ddf4..7b94ef26b03b6e19956e9d5a6a72ce2678001069 100644
|
2021-07-02 19:04:29 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -1320,7 +1320,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
2021-07-02 19:04:29 +00:00
|
|
|
speed = this.player.getAbilities().walkingSpeed * 10f;
|
|
|
|
}
|
|
|
|
// Paper start - Prevent moving into unloaded chunks
|
|
|
|
- if (player.level.paperConfig.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.hasChunk((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4)) {
|
|
|
|
+ if (player.level.paperConfig.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && worldserver.getChunkIfLoadedImmediately((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4) == null) { // Paper - use getIfLoadedImmediately
|
|
|
|
this.internalTeleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot(), Collections.emptySet(), true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
2022-03-01 05:43:03 +00:00
|
|
|
index c3ae2b4b5b4eb14d24f2c15a7e8ace8ebee84c1a..c293531a6913b365c3bf804d6d0bfae24378dc43 100644
|
2021-07-02 19:04:29 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -189,6 +189,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2021-07-02 19:04:29 +00:00
|
|
|
return (CraftServer) Bukkit.getServer();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public boolean hasChunk(int chunkX, int chunkZ) {
|
2021-11-24 23:26:29 +00:00
|
|
|
+ return this.getChunkIfLoaded(chunkX, chunkZ) != null;
|
2021-07-02 19:04:29 +00:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
2021-11-24 23:26:29 +00:00
|
|
|
public abstract ResourceKey<LevelStem> getTypeKey();
|
|
|
|
|
2022-03-01 05:43:03 +00:00
|
|
|
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor
|
|
|
|
@@ -1366,7 +1373,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2021-07-02 19:04:29 +00:00
|
|
|
|
|
|
|
for (int l1 = j; l1 <= l; ++l1) {
|
|
|
|
for (int i2 = k; i2 <= i1; ++i2) {
|
|
|
|
- LevelChunk chunk = this.getChunkSource().getChunkNow(l1, i2);
|
|
|
|
+ LevelChunk chunk = (LevelChunk) this.getChunkIfLoadedImmediately(l1, i2); // Paper
|
|
|
|
|
|
|
|
if (chunk != null) {
|
|
|
|
for (int j2 = j1; j2 <= k1; ++j2) {
|