Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 71 lines 2.4 kB view raw
1package net.minecraft.server; 2 3import java.io.*; 4 5public class ChunkRegionLoader implements IChunkLoader { 6 7 private final File a; 8 9 public ChunkRegionLoader(File file1) { 10 this.a = file1; 11 } 12 13 public Chunk a(World world, int i, int j) throws IOException { 14 DataInputStream datainputstream = RegionFileCache.c(this.a, i, j); 15 16 if (datainputstream != null) { 17 NBTTagCompound nbttagcompound = CompressedStreamTools.a((DataInput) datainputstream); 18 19 if (!nbttagcompound.hasKey("Level")) { 20 System.out.println("Chunk file at " + i + "," + j + " is missing level data, skipping"); 21 return null; 22 } else if (!nbttagcompound.k("Level").hasKey("Blocks")) { 23 System.out.println("Chunk file at " + i + "," + j + " is missing block data, skipping"); 24 return null; 25 } else { 26 Chunk chunk = ChunkLoader.a(world, nbttagcompound.k("Level")); 27 28 if (!chunk.a(i, j)) { 29 System.out.println("Chunk file at " + i + "," + j + " is in the wrong location; relocating. (Expected " + i + ", " + j + ", got " + chunk.x + ", " + chunk.z + ")"); 30 nbttagcompound.a("xPos", i); 31 nbttagcompound.a("zPos", j); 32 chunk = ChunkLoader.a(world, nbttagcompound.k("Level")); 33 } 34 35 chunk.h(); 36 return chunk; 37 } 38 } else { 39 return null; 40 } 41 } 42 43 public void a(World world, Chunk chunk) { 44 world.k(); 45 46 try { 47 DataOutputStream dataoutputstream = RegionFileCache.d(this.a, chunk.x, chunk.z); 48 NBTTagCompound nbttagcompound = new NBTTagCompound(); 49 NBTTagCompound nbttagcompound1 = new NBTTagCompound(); 50 51 nbttagcompound.a("Level", (NBTBase) nbttagcompound1); 52 ChunkLoader.a(chunk, world, nbttagcompound1); 53 CompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream); 54 dataoutputstream.close(); 55 WorldData worlddata = world.q(); 56 57 worlddata.b(worlddata.g() + (long) RegionFileCache.b(this.a, chunk.x, chunk.z)); 58 } catch (Exception exception) { 59 exception.printStackTrace(); 60 } 61 } 62 63 public void b(World world, Chunk chunk) { 64 } 65 66 public void a() { 67 } 68 69 public void b() { 70 } 71}