3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00

SPIGOT-4397: isChunkGenerated API

Dieser Commit ist enthalten in:
md_5 2018-09-26 17:19:16 +10:00
Ursprung 40aed54d11
Commit 1a7f2d109e
3 geänderte Dateien mit 33 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ChunkProviderServer.java
+++ b/net/minecraft/server/ChunkProviderServer.java
@@ -18,6 +18,11 @@
@@ -18,12 +18,17 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -12,6 +12,13 @@
public class ChunkProviderServer implements IChunkProvider {
private static final Logger a = LogManager.getLogger();
public final LongSet unloadQueue = new LongOpenHashSet();
public final ChunkGenerator<?> chunkGenerator;
- private final IChunkLoader chunkLoader;
+ public final IChunkLoader chunkLoader; // PAIL
public final Long2ObjectMap<Chunk> chunks = Long2ObjectMaps.synchronize(new ChunkMap(8192));
private Chunk lastChunk;
private final ChunkTaskScheduler chunkScheduler;
@@ -36,7 +41,7 @@
this.chunkLoader = ichunkloader;
this.chunkGenerator = chunkgenerator;

Datei anzeigen

@ -9,7 +9,7 @@
public ChunkRegionLoader(File file, DataFixer datafixer) {
this.c = file;
@@ -40,25 +40,60 @@
@@ -40,25 +40,64 @@
@Nullable
private NBTTagCompound a(GeneratorAccess generatoraccess, int i, int j) throws IOException {
@ -26,7 +26,7 @@
+ }
+ }
+
+ if (RegionFileCache.chunkExists(this.c, x, z)) {
+ if (this.chunkExists(x, z)) {
+ NBTTagCompound nbt = RegionFileCache.read(this.c, x, z);
+ if (nbt != null) {
+ NBTTagCompound level = nbt.getCompound("Level");
@ -42,6 +42,10 @@
+ }
+
+ return false;
+ }
+
+ public boolean chunkExists(int x, int z) {
+ return RegionFileCache.chunkExists(this.c, x, z);
}
@Nullable
@ -77,7 +81,7 @@
if (k < 1493) {
nbttagcompound1 = GameProfileSerializer.a(this.d, DataFixTypes.CHUNK, nbttagcompound1, k, 1493);
@@ -86,13 +121,29 @@
@@ -86,13 +125,29 @@
}
@ -107,7 +111,7 @@
Chunk chunk = this.a(generatoraccess, i, j, nbttagcompound);
if (chunk != null) {
@@ -101,6 +152,9 @@
@@ -101,6 +156,9 @@
}
return chunk;
@ -117,7 +121,7 @@
}
}
@@ -132,7 +186,7 @@
@@ -132,7 +190,7 @@
}
@Nullable
@ -126,7 +130,7 @@
if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) {
ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
@@ -151,10 +205,28 @@
@@ -151,10 +209,28 @@
ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ));
nbttagcompound1.setInt("xPos", i);
nbttagcompound1.setInt("zPos", j);
@ -156,7 +160,7 @@
}
}
} else {
@@ -169,7 +241,7 @@
@@ -169,7 +245,7 @@
ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
if (chunkstatus_type == ChunkStatus.Type.LEVELCHUNK) {
@ -165,7 +169,7 @@
} else {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level");
@@ -217,10 +289,14 @@
@@ -217,10 +293,14 @@
}
public boolean a() {
@ -182,7 +186,7 @@
ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName());
}
@@ -236,10 +312,14 @@
@@ -236,10 +316,14 @@
return true;
} else {
try {
@ -198,7 +202,7 @@
if (this.e != null) {
this.e.a(chunkcoordintpair.a());
}
@@ -266,15 +346,16 @@
@@ -266,15 +350,16 @@
public void b() {
try {
@ -218,7 +222,7 @@
}
}
@@ -303,7 +384,7 @@
@@ -303,7 +388,7 @@
if (abiomebase != null) {
for (int k = 0; k < abiomebase.length; ++k) {
@ -227,7 +231,7 @@
}
}
@@ -385,7 +466,7 @@
@@ -385,7 +470,7 @@
int[] aint = new int[abiomebase.length];
for (int i = 0; i < abiomebase.length; ++i) {
@ -236,7 +240,7 @@
}
nbttagcompound.setIntArray("Biomes", aint);
@@ -487,27 +568,27 @@
@@ -487,27 +572,27 @@
}
ChunkConverter chunkconverter = nbttagcompound.hasKeyOfType("UpgradeData", 10) ? new ChunkConverter(nbttagcompound.getCompound("UpgradeData")) : ChunkConverter.a;
@ -270,7 +274,7 @@
long i1 = nbttagcompound.getLong("InhabitedTime");
Chunk chunk = new Chunk(generatoraccess.getMinecraftWorld(), i, j, abiomebase, chunkconverter, protochunkticklist, protochunkticklist1, i1);
@@ -850,17 +931,29 @@
@@ -850,17 +935,29 @@
}
@Nullable
@ -302,7 +306,7 @@
});
}
@@ -874,8 +967,14 @@
@@ -874,8 +971,14 @@
}
}
@ -318,7 +322,7 @@
Iterator iterator = entity.bP().iterator();
while (iterator.hasNext()) {
@@ -891,7 +990,7 @@
@@ -891,7 +994,7 @@
boolean flag = false;
try {

Datei anzeigen

@ -146,6 +146,11 @@ public class CraftWorld implements World {
return world.getChunkProviderServer().isLoaded(x, z);
}
@Override
public boolean isChunkGenerated(int x, int z) {
return isChunkLoaded(x, z) || ((ChunkRegionLoader) world.getChunkProviderServer().chunkLoader).chunkExists(x, z);
}
public Chunk[] getLoadedChunks() {
Object[] chunks = world.getChunkProviderServer().chunks.values().toArray();
org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length];