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).
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2020-11-03 03:22:15 +01:00
|
|
|
index dabeeb95011225963d26fead2a58b0cb3c3f91fc..6cc86e36d6a5795b90e40c90526c8c93844a0942 100644
|
2019-07-18 06:41:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2020-11-03 03:22:15 +01:00
|
|
|
@@ -1084,7 +1084,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;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2020-11-03 03:22:15 +01:00
|
|
|
index e7ad9a926f58cc7e5d70229dd69f2f5b34603a39..7a392774de7affb344166cc3344b2ebf5468e299 100644
|
2019-07-18 06:41:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2020-06-26 18:20:03 +02:00
|
|
|
@@ -104,6 +104,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;
|
|
|
|
}
|
2020-11-03 03:22:15 +01:00
|
|
|
@@ -1002,14 +1009,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
|
|
|
}
|
2020-11-03 03:22:15 +01:00
|
|
|
@@ -1130,7 +1137,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);
|
2020-06-26 01:38:24 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-11-03 03:22:15 +01:00
|
|
|
index 5a85c5b99179ffe4cfbd994b4c75f6dffaed110f..6962e258446d7096accad7ec581fbbd57f020986 100644
|
2020-06-26 01:38:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-11-03 03:22:15 +01:00
|
|
|
@@ -95,7 +95,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-06-26 01:38:24 +02:00
|
|
|
}
|
|
|
|
|
2020-06-26 08:29:44 +02:00
|
|
|
@Override public Chunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
2020-06-26 01:38:24 +02:00
|
|
|
- return this.chunkProvider.getChunkAt(x, z, false);
|
|
|
|
+ return this.chunkProvider.getChunkAtIfLoadedImmediately(x, z); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paper start - Asynchronous IO
|
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
|
2020-06-26 01:38:24 +02:00
|
|
|
index 78f0fb5d97b077673ec542cd70bbc3ffa13f916c..b73af0a5fb2d08c2f3a52c699ef0d8ed34c83f77 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
|
|
|
|
@@ -143,9 +143,10 @@ public class ActivationRange
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|