2020-01-30 09:36:03 +00:00
|
|
|
From a39d46b1f933c5cf6a96525be0f31f1714b5205f 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).
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
2020-01-30 09:36:03 +00:00
|
|
|
index a92f251ca..2917e1bd4 100644
|
2019-07-18 04:41:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2019-12-16 02:47:23 +00:00
|
|
|
@@ -204,7 +204,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2019-07-18 04:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isChunkLoaded() {
|
|
|
|
- return world.isChunkLoaded((int) Math.floor(this.locX) >> 4, (int) Math.floor(this.locZ) >> 4);
|
|
|
|
+ return world.getChunkIfLoadedImmediately((int) Math.floor(this.locX) >> 4, (int) Math.floor(this.locZ) >> 4) != null; // Paper
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2020-01-30 09:36:03 +00:00
|
|
|
index 8c54022e0..f6fbba36f 100644
|
2019-07-18 04:41:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2019-12-16 02:47:23 +00:00
|
|
|
@@ -989,7 +989,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;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2020-01-30 09:36:03 +00:00
|
|
|
index 9d604a758..bfbbfb1ba 100644
|
2019-07-18 04:41:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2020-01-28 19:43:57 +00:00
|
|
|
@@ -114,8 +114,16 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2019-07-18 04:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Chunk getChunkIfLoaded(int x, int z) {
|
|
|
|
- return ((ChunkProviderServer) this.chunkProvider).getChunkAt(x, z, false);
|
|
|
|
+ return ((ChunkProviderServer) this.chunkProvider).getChunkAtIfLoadedImmediately(x, z); // Paper
|
|
|
|
}
|
2019-12-16 02:47:23 +00:00
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isChunkLoaded(int x, int z) {
|
|
|
|
+ return getChunkIfLoaded(x, z) != null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // Paper end
|
2019-07-18 04:41:24 +00:00
|
|
|
|
|
|
|
protected World(WorldData worlddata, DimensionManager dimensionmanager, BiFunction<World, WorldProvider, IChunkProvider> bifunction, GameProfilerFiller gameprofilerfiller, boolean flag, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) {
|
2019-12-16 02:47:23 +00:00
|
|
|
this.spigotConfig = new org.spigotmc.SpigotWorldConfig( worlddata.getName() ); // Spigot
|
2020-01-28 19:43:57 +00:00
|
|
|
@@ -1103,14 +1111,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2019-07-18 04:41:24 +00:00
|
|
|
}
|
|
|
|
|
2019-12-16 02:47:23 +00:00
|
|
|
public boolean n(BlockPosition blockposition) {
|
|
|
|
- return isOutsideWorld(blockposition) ? false : this.chunkProvider.b(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
|
|
+ return isOutsideWorld(blockposition) ? false : isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper
|
2019-07-18 04:41:24 +00:00
|
|
|
}
|
|
|
|
|
2019-12-16 02:47:23 +00:00
|
|
|
public boolean a(BlockPosition blockposition, Entity entity) {
|
|
|
|
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
|
|
|
|
|
|
|
|
return ichunkaccess == null ? false : ichunkaccess.getType(blockposition).a((IBlockAccess) this, blockposition, entity);
|
|
|
|
}
|
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
|
2020-01-30 09:36:03 +00:00
|
|
|
index f86404f83..92601c581 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
|
|
|
|
@@ -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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--
|
2020-01-28 19:43:57 +00:00
|
|
|
2.25.0
|
2019-07-18 04:41:24 +00:00
|
|
|
|