mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
more work
This commit is contained in:
parent
dfe0ef7ab1
commit
fb2577e08a
1 changed files with 69 additions and 91 deletions
|
@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||||
@@ -0,0 +0,0 @@ public class ChunkHolder {
|
@@ -0,0 +0,0 @@ public class ChunkHolder {
|
||||||
Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> either = (Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>) statusFuture.getNow(null);
|
Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> either = (Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>) statusFuture.getNow(null);
|
||||||
return either == null ? null : (LevelChunk) either.left().orElse(null);
|
return (either == null) ? null : (LevelChunk) either.left().orElse(null);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ public ChunkAccess getAvailableChunkNow() {
|
+ public ChunkAccess getAvailableChunkNow() {
|
||||||
|
@ -28,15 +28,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
// Paper end
|
// CraftBukkit end
|
||||||
|
|
||||||
public CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getFutureIfPresentUnchecked(ChunkStatus leastStatus) {
|
public CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getFutureIfPresentUnchecked(ChunkStatus leastStatus) {
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
@@ -0,0 +0,0 @@ import net.minecraft.world.level.chunk.ProtoChunk;
|
||||||
|
import net.minecraft.world.level.chunk.UpgradeData;
|
||||||
|
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||||
|
import net.minecraft.world.level.chunk.storage.ChunkStorage;
|
||||||
|
+import net.minecraft.world.level.chunk.storage.RegionFile;
|
||||||
|
import net.minecraft.world.level.entity.ChunkStatusUpdateListener;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||||
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
}
|
// Paper end
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
- private CompoundTag readChunk(ChunkPos pos) throws IOException {
|
- private CompoundTag readChunk(ChunkPos pos) throws IOException {
|
||||||
|
@ -60,15 +68,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ // Paper start - chunk status cache "api"
|
+ // Paper start - chunk status cache "api"
|
||||||
+ public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
|
+ public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
|
||||||
+ RegionFile regionFile = this.getIOWorker().getRegionFileCache().getRegionFileIfLoaded(chunkPos);
|
+ RegionFile regionFile = regionFileCache.getRegionFileIfLoaded(chunkPos);
|
||||||
+
|
|
||||||
|
- return nbttagcompound == null ? null : this.getChunkData(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, pos, level); // CraftBukkit
|
||||||
+ return regionFile == null ? null : regionFile.getStatusIfCached(chunkPos.x, chunkPos.z);
|
+ return regionFile == null ? null : regionFile.getStatusIfCached(chunkPos.x, chunkPos.z);
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ public ChunkStatus getChunkStatusOnDisk(ChunkPos chunkPos) throws IOException {
|
+ public ChunkStatus getChunkStatusOnDisk(ChunkPos chunkPos) throws IOException {
|
||||||
+ RegionFile regionFile = this.getIOWorker().getRegionFileCache().getFile(chunkPos, true);
|
+ RegionFile regionFile = regionFileCache.getFile(chunkPos, true);
|
||||||
+
|
+
|
||||||
+ if (regionFile == null || !regionFile.chunkExists(chunkPos)) {
|
+ if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) {
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -79,13 +88,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ this.readChunk(chunkPos);
|
+ this.readChunk(chunkPos);
|
||||||
|
+
|
||||||
- return nbttagcompound == null ? null : this.getChunkData(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, pos, level); // CraftBukkit
|
|
||||||
+ return regionFile.getStatusIfCached(chunkPos.x, chunkPos.z);
|
+ return regionFile.getStatusIfCached(chunkPos.x, chunkPos.z);
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ public void updateChunkStatusOnDisk(ChunkPos chunkPos, @Nullable CompoundTag compound) throws IOException {
|
+ public void updateChunkStatusOnDisk(ChunkPos chunkPos, @Nullable CompoundTag compound) throws IOException {
|
||||||
+ RegionFile regionFile = this.getIOWorker().getRegionFileCache().getFile(chunkPos, false);
|
+ RegionFile regionFile = regionFileCache.getFile(chunkPos, false);
|
||||||
+
|
+
|
||||||
+ regionFile.setStatus(chunkPos.x, chunkPos.z, ChunkSerializer.getStatus(compound));
|
+ regionFile.setStatus(chunkPos.x, chunkPos.z, ChunkSerializer.getStatus(compound));
|
||||||
+ }
|
+ }
|
||||||
|
@ -96,52 +104,44 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
boolean noPlayersCloseForSpawning(ChunkPos chunkcoordintpair) {
|
boolean noPlayersCloseForSpawning(ChunkPos chunkPos) {
|
||||||
// Spigot start
|
// Spigot start
|
||||||
return isOutsideOfRange(chunkcoordintpair, false);
|
return this.isOutsideOfRange(chunkPos, false);
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
private final ServerLevel level;
|
private static final List<ChunkStatus> CHUNK_STATUSES = ChunkStatus.getStatusList(); public static final List<ChunkStatus> getPossibleChunkStatuses() { return ServerChunkCache.CHUNK_STATUSES; } // Paper - OBFHELPER
|
||||||
public final Thread mainThread; // Paper - private -> public
|
private final DistanceManager distanceManager;
|
||||||
private final ThreadedLevelLightEngine lightEngine;
|
public final ChunkGenerator generator;
|
||||||
- private final ServerChunkCache.MainThreadExecutor mainThreadProcessor;
|
- final ServerLevel level;
|
||||||
|
- public final Thread mainThread; // Paper - package-private -> public
|
||||||
|
- final ThreadedLevelLightEngine lightEngine;
|
||||||
|
- public final ServerChunkCache.MainThreadExecutor mainThreadProcessor; // Paper - private -> public
|
||||||
|
+ private final ServerLevel level;
|
||||||
|
+ public final Thread mainThread; // Paper - private -> public
|
||||||
|
+ private final ThreadedLevelLightEngine lightEngine;
|
||||||
+ public final ServerChunkCache.MainThreadExecutor mainThreadProcessor; // Paper private -> public
|
+ public final ServerChunkCache.MainThreadExecutor mainThreadProcessor; // Paper private -> public
|
||||||
public final ChunkMap chunkMap;
|
public final ChunkMap chunkMap;
|
||||||
private final DimensionDataStorage dataStorage;
|
private final DimensionDataStorage dataStorage;
|
||||||
private long lastInhabitedUpdate;
|
private long lastInhabitedUpdate;
|
||||||
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
+
|
|
||||||
+ @Nullable
|
|
||||||
+ public ChunkAccess getChunkAtImmediately(int x, int z) {
|
|
||||||
+ long k = ChunkPos.asLong(x, z);
|
|
||||||
+
|
|
||||||
+ // Note: Bypass cache to make this MT-Safe
|
|
||||||
+
|
|
||||||
+ ChunkHolder playerChunk = this.getVisibleChunkIfPresent(k);
|
|
||||||
+ if (playerChunk == null) {
|
|
||||||
+ return null;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return playerChunk.getAvailableChunkNow();
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
// Paper end
|
// Paper end
|
||||||
|
// Paper start - async chunk io
|
||||||
@Nullable
|
+ @Nullable
|
||||||
|
public ChunkAccess getChunkAtImmediately(int x, int z) {
|
||||||
|
ChunkHolder holder = this.chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z));
|
||||||
|
if (holder == null) {
|
||||||
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
return this.lastSpawnState;
|
return this.lastSpawnState;
|
||||||
}
|
}
|
||||||
|
|
||||||
- final class MainThreadExecutor extends BlockableEventLoop<Runnable> {
|
- private final class MainThreadExecutor extends BlockableEventLoop<Runnable> {
|
||||||
+ public final class MainThreadExecutor extends BlockableEventLoop<Runnable> { // Paper - package -> public
|
+ public final class MainThreadExecutor extends BlockableEventLoop<Runnable> { // Paper - package -> public
|
||||||
|
|
||||||
private MainThreadExecutor(Level world) {
|
MainThreadExecutor(Level world) {
|
||||||
super("Chunk source main thread executor for " + world.dimension().location());
|
super("Chunk source main thread executor for " + world.dimension().location());
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java b/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java b/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
@ -178,8 +178,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||||
@@ -0,0 +0,0 @@ public class ChunkSerializer {
|
@@ -0,0 +0,0 @@ public class ChunkSerializer {
|
||||||
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
// Paper end
|
|
||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ public static ChunkStatus getStatus(CompoundTag compound) {
|
+ public static ChunkStatus getStatus(CompoundTag compound) {
|
||||||
|
@ -192,29 +192,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
public static ChunkStatus.ChunkType getChunkTypeFromTag(@Nullable CompoundTag tag) {
|
public static ChunkStatus.ChunkType getChunkTypeFromTag(@Nullable CompoundTag nbt) {
|
||||||
if (tag != null) {
|
if (nbt != null) {
|
||||||
ChunkStatus chunkstatus = ChunkStatus.byName(tag.getCompound("Level").getString("Status"));
|
ChunkStatus chunkstatus = ChunkStatus.byName(nbt.getCompound("Level").getString("Status"));
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.world.level.storage.DimensionDataStorage;
|
|
||||||
|
|
||||||
public class ChunkStorage implements AutoCloseable {
|
|
||||||
|
|
||||||
- private final IOWorker worker;
|
|
||||||
+ private final IOWorker worker; public IOWorker getIOWorker() { return worker; } // Paper - OBFHELPER
|
|
||||||
protected final DataFixer fixerUpper;
|
|
||||||
@Nullable
|
|
||||||
private LegacyStructureDataHandler legacyStructureHandler;
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.Util;
|
@@ -0,0 +0,0 @@ import java.nio.file.StandardOpenOption;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.nbt.NbtIo;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
+import net.minecraft.world.level.chunk.ChunkStatus;
|
+import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
@ -222,7 +209,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
|
@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
|
||||||
protected final RegionBitmap usedSectors;
|
protected final RegionBitmap usedSectors;
|
||||||
public final File file; // Paper
|
public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(true); // Paper
|
||||||
|
|
||||||
+ // Paper start - Cache chunk status
|
+ // Paper start - Cache chunk status
|
||||||
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
|
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
|
||||||
|
@ -259,8 +246,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
private static int getOffsetIndex(ChunkPos pos) {
|
private static int getOffsetIndex(ChunkPos pos) {
|
||||||
return pos.getRegionLocalX() + pos.getRegionLocalZ() * 32;
|
return pos.getRegionLocalX() + pos.getRegionLocalZ() * 32;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
|
||||||
public void close() throws IOException {
|
synchronized (this) {
|
||||||
|
try {
|
||||||
|
// Paper end
|
||||||
+ this.closed = true; // Paper
|
+ this.closed = true; // Paper
|
||||||
try {
|
try {
|
||||||
this.padToFullSector();
|
this.padToFullSector();
|
||||||
|
@ -269,30 +258,19 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable {
|
@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { // Paper - no final
|
||||||
this.sync = dsync;
|
|
||||||
}
|
|
||||||
|
|
||||||
- private RegionFile getFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit
|
|
||||||
+
|
|
||||||
+ // Paper start
|
|
||||||
+ public RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) {
|
|
||||||
+ return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // Paper end
|
|
||||||
+ public RegionFile getFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Paper - private > public
|
|
||||||
long i = ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ());
|
|
||||||
RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i);
|
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
NbtIo.write(tag, (DataOutput) dataoutputstream);
|
NbtIo.write(nbt, (DataOutput) dataoutputstream);
|
||||||
+ regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(tag)); // Paper - cache status on disk
|
+ regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - cache status on disk
|
||||||
regionfile.setOversized(pos.x, pos.z, false); // Paper - We don't do this anymore, mojang stores differently, but clear old meta flag if it exists to get rid of our own meta file once last oversized is gone
|
} catch (Throwable throwable) {
|
||||||
} catch (Throwable throwable1) {
|
if (dataoutputstream != null) {
|
||||||
throwable = throwable1;
|
try {
|
||||||
|
@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { // Paper - no final
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
|
@ -323,7 +301,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return chunk instanceof ImposterProtoChunk || chunk instanceof net.minecraft.world.level.chunk.LevelChunk;
|
+ return chunk instanceof ImposterProtoChunk || chunk instanceof net.minecraft.world.level.chunk.LevelChunk;
|
||||||
+ }
|
+ }
|
||||||
try {
|
try {
|
||||||
- return world.getChunkSource().getChunkAtIfCachedImmediately(x, z) != null || world.getChunkSource().chunkMap.read(new ChunkPos(x, z)) != null; // Paper (TODO check if the first part can be removed)
|
- return this.world.getChunkSource().getChunkAtIfCachedImmediately(x, z) != null || this.world.getChunkSource().chunkMap.read(new ChunkPos(x, z)) != null; // Paper (TODO check if the first part can be removed)
|
||||||
+ return world.getChunkSource().chunkMap.getChunkStatusOnDisk(new ChunkPos(x, z)) == ChunkStatus.FULL;
|
+ return world.getChunkSource().chunkMap.getChunkStatusOnDisk(new ChunkPos(x, z)) == ChunkStatus.FULL;
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
@ -333,14 +311,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
@Override
|
@Override
|
||||||
public boolean loadChunk(int x, int z, boolean generate) {
|
public boolean loadChunk(int x, int z, boolean generate) {
|
||||||
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
||||||
- ChunkAccess chunk = world.getChunkSource().getChunk(x, z, generate || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // Paper
|
- ChunkAccess chunk = this.world.getChunkSource().getChunk(x, z, generate || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // Paper
|
||||||
+ // Paper start - Optimize this method
|
+ // Paper start - Optimize this method
|
||||||
+ ChunkPos chunkPos = new ChunkPos(x, z);
|
+ ChunkPos chunkPos = new ChunkPos(x, z);
|
||||||
|
|
||||||
- // If generate = false, but the chunk already exists, we will get this back.
|
- // If generate = false, but the chunk already exists, we will get this back.
|
||||||
- if (chunk instanceof ImposterProtoChunk) {
|
- if (chunk instanceof ImposterProtoChunk) {
|
||||||
- // We then cycle through again to get the full chunk immediately, rather than after the ticket addition
|
- // We then cycle through again to get the full chunk immediately, rather than after the ticket addition
|
||||||
- chunk = world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);
|
- chunk = this.world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);
|
||||||
- }
|
- }
|
||||||
+ if (!generate) {
|
+ if (!generate) {
|
||||||
+ ChunkAccess immediate = world.getChunkSource().getChunkAtImmediately(x, z);
|
+ ChunkAccess immediate = world.getChunkSource().getChunkAtImmediately(x, z);
|
||||||
|
@ -357,11 +335,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
- if (chunk instanceof net.minecraft.world.level.chunk.LevelChunk) {
|
- if (chunk instanceof net.minecraft.world.level.chunk.LevelChunk) {
|
||||||
- world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE);
|
- this.world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE);
|
||||||
- return true;
|
- return true;
|
||||||
+ net.minecraft.world.level.chunk.storage.RegionFile file;
|
+ net.minecraft.world.level.chunk.storage.RegionFile file;
|
||||||
+ try {
|
+ try {
|
||||||
+ file = world.getChunkSource().chunkMap.getIOWorker().getRegionFileCache().getFile(chunkPos, false);
|
+ file = world.getChunkSource().chunkMap.regionFileCache.getFile(chunkPos, false);
|
||||||
+ } catch (IOException ex) {
|
+ } catch (IOException ex) {
|
||||||
+ throw new RuntimeException(ex);
|
+ throw new RuntimeException(ex);
|
||||||
+ }
|
+ }
|
Loading…
Reference in a new issue