2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-07-18 04:41:24 +00: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 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
2021-06-11 06:29:15 +00:00
|
|
|
index 52d22da115212eae6c380bb5012398e3df92f5f3..13c99bdb8894d08f297f84ee1f98f50c811f7f4b 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -207,7 +207,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2021-03-16 07:19:45 +00: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-06-11 06:29:15 +00:00
|
|
|
index d74d6abfff647c148e524905cd733c4b7fc6591f..24dfdb3807dbf6e9acc59d35d7c76f7ac0185219 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-04-18 09:02:48 +00:00
|
|
|
@@ -1244,7 +1244,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2019-07-18 04:41:24 +00:00
|
|
|
speed = player.abilities.walkSpeed * 10f;
|
|
|
|
}
|
|
|
|
// Paper start - Prevent moving into unloaded chunks
|
2019-12-16 02:47:23 +00: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 04:41:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-03-16 07:19:45 +00: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 13:04:28 +00:00
|
|
|
index 15da3511a9e57c320f4cf409852bee07109095bc..b620d7e0d824c8d0758a66a8fbe872c3e45103d2 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/World.java
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -164,6 +164,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2020-06-25 23:38:24 +00:00
|
|
|
return (CraftServer) Bukkit.getServer();
|
2019-07-18 04:41:24 +00:00
|
|
|
}
|
|
|
|
|
2019-12-16 02:47:23 +00:00
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isChunkLoaded(int x, int z) {
|
2020-06-25 23:38:24 +00:00
|
|
|
+ return ((WorldServer)this).getChunkIfLoaded(x, z) != null;
|
2019-12-16 02:47:23 +00:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2020-06-25 23:38:24 +00:00
|
|
|
+
|
2020-08-25 02:22:08 +00:00
|
|
|
public ResourceKey<DimensionManager> getTypeKey() {
|
|
|
|
return typeKey;
|
|
|
|
}
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -1062,14 +1069,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2019-07-18 04:41:24 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 23:38:24 +00:00
|
|
|
public boolean p(BlockPosition blockposition) {
|
|
|
|
- return isOutsideWorld(blockposition) ? false : this.getChunkProvider().b(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
2019-12-16 02:47:23 +00:00
|
|
|
+ return isOutsideWorld(blockposition) ? false : isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper
|
2019-07-18 04:41:24 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 23:38:24 +00:00
|
|
|
public boolean a(BlockPosition blockposition, Entity entity, EnumDirection enumdirection) {
|
2019-12-16 02:47:23 +00: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-25 23:38:24 +00:00
|
|
|
return ichunkaccess == null ? false : ichunkaccess.getType(blockposition).a((IBlockAccess) this, blockposition, entity, enumdirection);
|
2019-12-16 02:47:23 +00:00
|
|
|
}
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -1190,7 +1197,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2020-04-24 07:01:17 +00: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 04:41:24 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
2021-03-16 07:19:45 +00:00
|
|
|
index 58d22363124a9343188d8c19476e5a92f2f0b80b..53d0541aba207b5eaea2e49edbb56df918d30333 100644
|
2019-07-18 04:41:24 +00:00
|
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -140,9 +140,10 @@ public class ActivationRange
|
2019-07-18 04:41:24 +00: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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|