public Chunk loadChunk(World world, int i, int j) { DataInputStream datainputstream = RegionFileCache.func_22124_c(field_22110_a, i, j); NBTTagCompound nbttagcompound; if (datainputstream != null) { nbttagcompound = CompressedStreamTools.func_774_a(datainputstream); } else { return(null); } if (!nbttagcompound.hasKey("Level")) { [email protected]( (new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j).append( " is missing level data, skipping").toString()); return(null); } if (!nbttagcompound.getCompoundTag("Level").hasKey("Blocks")) { [email protected]( (new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j).append( " is missing block data, skipping").toString()); return(null); } Chunk chunk = ChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level")); if (!chunk.isAtLocation(i, j)) { [email protected]( (new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j).append( " is in the wrong location; relocating. (Expected ").append(i).append(", ").append(j).append( ", got ").append(chunk.xPosition).append(", ").append(chunk.zPosition).append(")").toString()); nbttagcompound.setInteger("xPos", i); nbttagcompound.setInteger("zPos", j); chunk = ChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level")); } return(chunk); }
public void saveChunk(World world, Chunk chunk) { world.checkSessionLock(); try { DataOutputStream dataoutputstream = RegionFileCache.func_22120_d(field_22110_a, chunk.xPosition, chunk.zPosition); var nbttagcompound = new NBTTagCompound(); var nbttagcompound1 = new NBTTagCompound(); nbttagcompound.setTag("Level", nbttagcompound1); ChunkLoader.storeChunkInCompound(chunk, world, nbttagcompound1); CompressedStreamTools.func_771_a(nbttagcompound, dataoutputstream); dataoutputstream.close(); WorldInfo worldinfo = world.getWorldInfo(); worldinfo.func_22177_b(worldinfo.func_22182_g() + RegionFileCache.func_22121_b(field_22110_a, chunk.xPosition, chunk.zPosition)); } catch (Exception exception) { exception.printStackTrace(); } }