mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 14:33:56 +01:00
117 lines
4.5 KiB
Diff
117 lines
4.5 KiB
Diff
--- a/net/minecraft/server/ChunkRegionLoader.java
|
|
+++ b/net/minecraft/server/ChunkRegionLoader.java
|
|
@@ -28,7 +28,35 @@
|
|
this.e = dataconvertermanager;
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ public boolean chunkExists(World world, int i, int j) {
|
|
+ ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
|
|
+
|
|
+ if (this.c.contains(chunkcoordintpair)) {
|
|
+ if (this.b.containsKey(chunkcoordintpair)) {
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return RegionFileCache.a(this.d, i, j).chunkExists(i & 31, j & 31);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
+ // CraftBukkit start - Add async variant, provide compatibility
|
|
public Chunk a(World world, int i, int j) throws IOException {
|
|
+ Object[] data = loadChunk(world, i, j);
|
|
+ if (data != null) {
|
|
+ Chunk chunk = (Chunk) data[0];
|
|
+ NBTTagCompound nbttagcompound = (NBTTagCompound) data[1];
|
|
+ loadEntities(chunk, nbttagcompound.getCompound("Level"), world);
|
|
+ return chunk;
|
|
+ }
|
|
+
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ public Object[] loadChunk(World world, int i, int j) throws IOException {
|
|
+ // CraftBukkit end
|
|
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
|
|
NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair);
|
|
|
|
@@ -45,7 +73,7 @@
|
|
return this.a(world, i, j, nbttagcompound);
|
|
}
|
|
|
|
- protected Chunk a(World world, int i, int j, NBTTagCompound nbttagcompound) {
|
|
+ protected Object[] a(World world, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[]
|
|
if (!nbttagcompound.hasKeyOfType("Level", 10)) {
|
|
ChunkRegionLoader.a.error("Chunk file at " + i + "," + j + " is missing level data, skipping");
|
|
return null;
|
|
@@ -62,10 +90,28 @@
|
|
ChunkRegionLoader.a.error("Chunk file at " + i + "," + j + " is in the wrong location; relocating. (Expected " + i + ", " + j + ", got " + chunk.locX + ", " + chunk.locZ + ")");
|
|
nbttagcompound1.setInt("xPos", i);
|
|
nbttagcompound1.setInt("zPos", j);
|
|
+
|
|
+ // CraftBukkit start - Have to move tile entities since we don't load them at this stage
|
|
+ NBTTagList tileEntities = nbttagcompound.getCompound("Level").getList("TileEntities", 10);
|
|
+ if (tileEntities != null) {
|
|
+ for (int te = 0; te < tileEntities.size(); te++) {
|
|
+ NBTTagCompound tileEntity = (NBTTagCompound) tileEntities.get(te);
|
|
+ int x = tileEntity.getInt("x") - chunk.locX * 16;
|
|
+ int z = tileEntity.getInt("z") - chunk.locZ * 16;
|
|
+ tileEntity.setInt("x", i * 16 + x);
|
|
+ tileEntity.setInt("z", j * 16 + z);
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
chunk = this.a(world, nbttagcompound1);
|
|
}
|
|
|
|
- return chunk;
|
|
+ // CraftBukkit start
|
|
+ Object[] data = new Object[2];
|
|
+ data[0] = chunk;
|
|
+ data[1] = nbttagcompound;
|
|
+ return data;
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
}
|
|
@@ -295,6 +341,13 @@
|
|
chunk.a(nbttagcompound.getByteArray("Biomes"));
|
|
}
|
|
|
|
+ // CraftBukkit start - End this method here and split off entity loading to another method
|
|
+ return chunk;
|
|
+ }
|
|
+
|
|
+ public void loadEntities(Chunk chunk, NBTTagCompound nbttagcompound, World world) {
|
|
+ // CraftBukkit end
|
|
+
|
|
NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
|
|
|
|
if (nbttaglist1 != null) {
|
|
@@ -338,7 +391,7 @@
|
|
}
|
|
}
|
|
|
|
- return chunk;
|
|
+ // return chunk; // CraftBukkit
|
|
}
|
|
|
|
public static Entity a(NBTTagCompound nbttagcompound, World world, Chunk chunk) {
|
|
@@ -399,8 +452,14 @@
|
|
}
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
public static void a(Entity entity, World world) {
|
|
- if (world.addEntity(entity) && entity.isVehicle()) {
|
|
+ a(entity, world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
|
+ }
|
|
+
|
|
+ public static void a(Entity entity, World world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
|
+ if (world.addEntity(entity, reason) && entity.isVehicle()) {
|
|
+ // CraftBukkit end
|
|
Iterator iterator = entity.bu().iterator();
|
|
|
|
while (iterator.hasNext()) {
|