mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 17:07:34 +01:00
SPIGOT-4397: isChunkGenerated API
This commit is contained in:
parent
40aed54d11
commit
1a7f2d109e
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/server/ChunkProviderServer.java
|
--- a/net/minecraft/server/ChunkProviderServer.java
|
||||||
+++ b/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.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@ -12,6 +12,13 @@
|
|||||||
public class ChunkProviderServer implements IChunkProvider {
|
public class ChunkProviderServer implements IChunkProvider {
|
||||||
|
|
||||||
private static final Logger a = LogManager.getLogger();
|
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 @@
|
@@ -36,7 +41,7 @@
|
||||||
this.chunkLoader = ichunkloader;
|
this.chunkLoader = ichunkloader;
|
||||||
this.chunkGenerator = chunkgenerator;
|
this.chunkGenerator = chunkgenerator;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
public ChunkRegionLoader(File file, DataFixer datafixer) {
|
public ChunkRegionLoader(File file, DataFixer datafixer) {
|
||||||
this.c = file;
|
this.c = file;
|
||||||
@@ -40,25 +40,60 @@
|
@@ -40,25 +40,64 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private NBTTagCompound a(GeneratorAccess generatoraccess, int i, int j) throws IOException {
|
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);
|
+ NBTTagCompound nbt = RegionFileCache.read(this.c, x, z);
|
||||||
+ if (nbt != null) {
|
+ if (nbt != null) {
|
||||||
+ NBTTagCompound level = nbt.getCompound("Level");
|
+ NBTTagCompound level = nbt.getCompound("Level");
|
||||||
@ -42,6 +42,10 @@
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ return false;
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean chunkExists(int x, int z) {
|
||||||
|
+ return RegionFileCache.chunkExists(this.c, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -77,7 +81,7 @@
|
|||||||
|
|
||||||
if (k < 1493) {
|
if (k < 1493) {
|
||||||
nbttagcompound1 = GameProfileSerializer.a(this.d, DataFixTypes.CHUNK, nbttagcompound1, 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);
|
Chunk chunk = this.a(generatoraccess, i, j, nbttagcompound);
|
||||||
|
|
||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
@@ -101,6 +152,9 @@
|
@@ -101,6 +156,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return chunk;
|
return chunk;
|
||||||
@ -117,7 +121,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +186,7 @@
|
@@ -132,7 +190,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -126,7 +130,7 @@
|
|||||||
if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) {
|
if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) {
|
||||||
ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
|
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));
|
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("xPos", i);
|
||||||
nbttagcompound1.setInt("zPos", j);
|
nbttagcompound1.setInt("zPos", j);
|
||||||
@ -156,7 +160,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -169,7 +241,7 @@
|
@@ -169,7 +245,7 @@
|
||||||
ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
|
ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
|
||||||
|
|
||||||
if (chunkstatus_type == ChunkStatus.Type.LEVELCHUNK) {
|
if (chunkstatus_type == ChunkStatus.Type.LEVELCHUNK) {
|
||||||
@ -165,7 +169,7 @@
|
|||||||
} else {
|
} else {
|
||||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level");
|
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level");
|
||||||
|
|
||||||
@@ -217,10 +289,14 @@
|
@@ -217,10 +293,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean a() {
|
public boolean a() {
|
||||||
@ -182,7 +186,7 @@
|
|||||||
ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName());
|
ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,10 +312,14 @@
|
@@ -236,10 +316,14 @@
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -198,7 +202,7 @@
|
|||||||
if (this.e != null) {
|
if (this.e != null) {
|
||||||
this.e.a(chunkcoordintpair.a());
|
this.e.a(chunkcoordintpair.a());
|
||||||
}
|
}
|
||||||
@@ -266,15 +346,16 @@
|
@@ -266,15 +350,16 @@
|
||||||
|
|
||||||
public void b() {
|
public void b() {
|
||||||
try {
|
try {
|
||||||
@ -218,7 +222,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -303,7 +384,7 @@
|
@@ -303,7 +388,7 @@
|
||||||
|
|
||||||
if (abiomebase != null) {
|
if (abiomebase != null) {
|
||||||
for (int k = 0; k < abiomebase.length; ++k) {
|
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];
|
int[] aint = new int[abiomebase.length];
|
||||||
|
|
||||||
for (int i = 0; i < abiomebase.length; ++i) {
|
for (int i = 0; i < abiomebase.length; ++i) {
|
||||||
@ -236,7 +240,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
nbttagcompound.setIntArray("Biomes", aint);
|
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;
|
ChunkConverter chunkconverter = nbttagcompound.hasKeyOfType("UpgradeData", 10) ? new ChunkConverter(nbttagcompound.getCompound("UpgradeData")) : ChunkConverter.a;
|
||||||
@ -270,7 +274,7 @@
|
|||||||
long i1 = nbttagcompound.getLong("InhabitedTime");
|
long i1 = nbttagcompound.getLong("InhabitedTime");
|
||||||
Chunk chunk = new Chunk(generatoraccess.getMinecraftWorld(), i, j, abiomebase, chunkconverter, protochunkticklist, protochunkticklist1, i1);
|
Chunk chunk = new Chunk(generatoraccess.getMinecraftWorld(), i, j, abiomebase, chunkconverter, protochunkticklist, protochunkticklist1, i1);
|
||||||
|
|
||||||
@@ -850,17 +931,29 @@
|
@@ -850,17 +935,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -302,7 +306,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,8 +967,14 @@
|
@@ -874,8 +971,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +322,7 @@
|
|||||||
Iterator iterator = entity.bP().iterator();
|
Iterator iterator = entity.bP().iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -891,7 +990,7 @@
|
@@ -891,7 +994,7 @@
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -146,6 +146,11 @@ public class CraftWorld implements World {
|
|||||||
return world.getChunkProviderServer().isLoaded(x, z);
|
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() {
|
public Chunk[] getLoadedChunks() {
|
||||||
Object[] chunks = world.getChunkProviderServer().chunks.values().toArray();
|
Object[] chunks = world.getChunkProviderServer().chunks.values().toArray();
|
||||||
org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length];
|
org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length];
|
||||||
|
Loading…
Reference in New Issue
Block a user