geforkt von Mirrors/Paper
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
120 Zeilen
7.0 KiB
Diff
120 Zeilen
7.0 KiB
Diff
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
|
|
index 95eff4f6165024d21e5c4268a9ae1b7a4268de4b..9d4c81a4964317a0726171dc6d490d12bd959cc4 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -201,7 +201,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
|
}
|
|
|
|
@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
|
|
}
|
|
|
|
// Paper start - Asynchronous IO
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 5dd99709d6b0ed15bbcee184fe33a28bc1c19dac..e45690b6197335ed1c07fa04c39b311b401724d7 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1242,7 +1242,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
|
|
speed = player.abilities.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.yRot, this.player.xRot, Collections.emptySet());
|
|
return;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
|
index d082af8cf4c0c7ca434598aa370712c62e05bb24..b9d32e3322c2cce1aca2a90df71b6175a6f8c548 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
|
@@ -284,10 +284,10 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
|
// Paper start - Asynchronous chunk io
|
|
@javax.annotation.Nullable
|
|
@Override
|
|
- public CompoundTag read(ChunkPos chunkcoordintpair) throws java.io.IOException {
|
|
+ public CompoundTag read(ChunkPos pos) throws java.io.IOException {
|
|
if (this.world != null && Thread.currentThread() != com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE) {
|
|
CompoundTag ret = com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE
|
|
- .loadChunkDataAsyncFuture(this.world, chunkcoordintpair.x, chunkcoordintpair.z, com.destroystokyo.paper.io.IOUtil.getPriorityForCurrentThread(),
|
|
+ .loadChunkDataAsyncFuture(this.world, pos.x, pos.z, com.destroystokyo.paper.io.IOUtil.getPriorityForCurrentThread(),
|
|
true, false, true).join().poiData;
|
|
|
|
if (ret == com.destroystokyo.paper.io.PaperFileIOThread.FAILURE_VALUE) {
|
|
@@ -295,18 +295,18 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
|
}
|
|
return ret;
|
|
}
|
|
- return super.read(chunkcoordintpair);
|
|
+ return super.read(pos);
|
|
}
|
|
|
|
@Override
|
|
- public void write(ChunkPos chunkcoordintpair, CompoundTag nbttagcompound) throws java.io.IOException {
|
|
+ public void write(ChunkPos pos, CompoundTag tag) throws java.io.IOException {
|
|
if (this.world != null && Thread.currentThread() != com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE) {
|
|
com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE.scheduleSave(
|
|
- this.world, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound, null,
|
|
+ this.world, pos.x, pos.z, tag, null,
|
|
com.destroystokyo.paper.io.IOUtil.getPriorityForCurrentThread());
|
|
return;
|
|
}
|
|
- super.write(chunkcoordintpair, nbttagcompound);
|
|
+ super.write(pos, tag);
|
|
}
|
|
// Paper end
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 1377465e3dc062f34be25cac10aa018776fb22e7..3a1b9f1ba19b28cebdafeb3b2476217d47213862 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -164,6 +164,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
return (CraftServer) Bukkit.getServer();
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public boolean hasChunk(int chunkX, int chunkZ) {
|
|
+ return ((ServerLevel)this).getChunkIfLoaded(chunkX, chunkZ) != null;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public ResourceKey<DimensionType> getTypeKey() {
|
|
return typeKey;
|
|
}
|
|
@@ -1190,7 +1197,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
|
|
for (int i1 = i; i1 < j; ++i1) {
|
|
for (int j1 = k; j1 < l; ++j1) {
|
|
- LevelChunk chunk = ichunkprovider.getChunkNow(i1, j1);
|
|
+ LevelChunk chunk = (LevelChunk)this.getChunkIfLoadedImmediately(i1, j1); // Paper
|
|
|
|
if (chunk != null) {
|
|
chunk.getEntitiesOfClass(entityClass, box, list, predicate);
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index 0a9bd85e0308e962df3b24a74bd5aac919744d6d..61f180a7c95d83bb88c7df4910c498d9bdf6785a 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -140,9 +140,10 @@ public class ActivationRange
|
|
{
|
|
for ( int j1 = k; j1 <= l; ++j1 )
|
|
{
|
|
- if ( world.getWorld().isChunkLoaded( i1, j1 ) )
|
|
+ LevelChunk chunk = (LevelChunk) world.getChunkIfLoadedImmediately( i1, j1 );
|
|
+ if ( chunk != null )
|
|
{
|
|
- activateChunkEntities( world.getChunk( i1, j1 ) );
|
|
+ activateChunkEntities( chunk );
|
|
}
|
|
}
|
|
}
|