2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-07-18 06:41:24 +02:00
|
|
|
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).
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
2021-04-18 11:02:48 +02:00
|
|
|
index a68be9b72daca6353d51141a8771e00240375315..fe662ea8acb873aac2fc3b29addbef77854494ed 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
2021-03-16 14:04:28 +01:00
|
|
|
@@ -207,7 +207,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2021-03-16 08:19:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override public Chunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
|
|
|
- return this.chunkProvider.getChunkAt(x, z, false);
|
|
|
|
+ return this.chunkProvider.getChunkAtIfLoadedImmediately(x, z); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paper start - Asynchronous IO
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-04-18 11:02:48 +02:00
|
|
|
index fa0b7edf42243d53d9dc897903b9b9e902b33cf7..eee5b3e4645ae41f63aba8898c58f43402d31b73 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-04-18 11:02:48 +02:00
|
|
|
@@ -1244,7 +1244,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2019-07-18 06:41:24 +02:00
|
|
|
speed = player.abilities.walkSpeed * 10f;
|
|
|
|
}
|
|
|
|
// Paper start - Prevent moving into unloaded chunks
|
2019-12-16 03:47:23 +01:00
|
|
|
- if (player.world.paperConfig.preventMovingIntoUnloadedChunks && (this.player.locX() != toX || this.player.locZ() != toZ) && !worldserver.isChunkLoaded((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4)) {
|
|
|
|
+ if (player.world.paperConfig.preventMovingIntoUnloadedChunks && (this.player.locX() != toX || this.player.locZ() != toZ) && worldserver.getChunkIfLoadedImmediately((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4) == null) { // Paper - use getIfLoadedImmediately
|
|
|
|
this.internalTeleport(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.yaw, this.player.pitch, Collections.emptySet());
|
2019-07-18 06:41:24 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
|
2021-03-16 14:04:28 +01:00
|
|
|
index 15da3511a9e57c320f4cf409852bee07109095bc..b620d7e0d824c8d0758a66a8fbe872c3e45103d2 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/World.java
|
2021-03-16 14:04:28 +01:00
|
|
|
@@ -164,6 +164,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2020-06-26 01:38:24 +02:00
|
|
|
return (CraftServer) Bukkit.getServer();
|
2019-07-18 06:41:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-16 03:47:23 +01:00
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isChunkLoaded(int x, int z) {
|
2020-06-26 01:38:24 +02:00
|
|
|
+ return ((WorldServer)this).getChunkIfLoaded(x, z) != null;
|
2019-12-16 03:47:23 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2020-06-26 01:38:24 +02:00
|
|
|
+
|
2020-08-25 04:22:08 +02:00
|
|
|
public ResourceKey<DimensionManager> getTypeKey() {
|
|
|
|
return typeKey;
|
|
|
|
}
|
2021-03-16 14:04:28 +01:00
|
|
|
@@ -1062,14 +1069,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2019-07-18 06:41:24 +02:00
|
|
|
}
|
|
|
|
|
2020-06-26 01:38:24 +02:00
|
|
|
public boolean p(BlockPosition blockposition) {
|
|
|
|
- return isOutsideWorld(blockposition) ? false : this.getChunkProvider().b(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
2019-12-16 03:47:23 +01:00
|
|
|
+ return isOutsideWorld(blockposition) ? false : isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper
|
2019-07-18 06:41:24 +02:00
|
|
|
}
|
|
|
|
|
2020-06-26 01:38:24 +02:00
|
|
|
public boolean a(BlockPosition blockposition, Entity entity, EnumDirection enumdirection) {
|
2019-12-16 03:47:23 +01:00
|
|
|
if (isOutsideWorld(blockposition)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
- IChunkAccess ichunkaccess = this.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4, ChunkStatus.FULL, false);
|
|
|
|
+ IChunkAccess ichunkaccess = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper
|
|
|
|
|
2020-06-26 01:38:24 +02:00
|
|
|
return ichunkaccess == null ? false : ichunkaccess.getType(blockposition).a((IBlockAccess) this, blockposition, entity, enumdirection);
|
2019-12-16 03:47:23 +01:00
|
|
|
}
|
2021-03-16 14:04:28 +01:00
|
|
|
@@ -1190,7 +1197,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2020-04-24 09:01:17 +02:00
|
|
|
|
|
|
|
for (int i1 = i; i1 < j; ++i1) {
|
|
|
|
for (int j1 = k; j1 < l; ++j1) {
|
|
|
|
- Chunk chunk = ichunkprovider.a(i1, j1);
|
|
|
|
+ Chunk chunk = (Chunk)this.getChunkIfLoadedImmediately(i1, j1); // Paper
|
|
|
|
|
|
|
|
if (chunk != null) {
|
|
|
|
chunk.a(oclass, axisalignedbb, list, predicate);
|
2019-07-18 06:41:24 +02:00
|
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
2021-03-16 08:19:45 +01:00
|
|
|
index 58d22363124a9343188d8c19476e5a92f2f0b80b..53d0541aba207b5eaea2e49edbb56df918d30333 100644
|
2019-07-18 06:41:24 +02:00
|
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
2021-03-16 08:19:45 +01:00
|
|
|
@@ -140,9 +140,10 @@ public class ActivationRange
|
2019-07-18 06:41:24 +02:00
|
|
|
{
|
|
|
|
for ( int j1 = k; j1 <= l; ++j1 )
|
|
|
|
{
|
|
|
|
- if ( world.getWorld().isChunkLoaded( i1, j1 ) )
|
|
|
|
+ Chunk chunk = (Chunk) world.getChunkIfLoadedImmediately( i1, j1 );
|
|
|
|
+ if ( chunk != null )
|
|
|
|
{
|
|
|
|
- activateChunkEntities( world.getChunkAt( i1, j1 ) );
|
|
|
|
+ activateChunkEntities( chunk );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|