Example #1
0
        public void saveChunk(World world, Chunk chunk)
        {
            world.checkSessionLock();
            File file = chunkFileForXZ(chunk.xPosition, chunk.zPosition);

            if (file.exists())
            {
                WorldInfo worldinfo = world.getWorldInfo();
                worldinfo.func_22177_b(worldinfo.func_22182_g() - file.length());
            }
            try
            {
                var file1            = new File(saveDir, "tmp_chunk.dat");
                var fileoutputstream = new FileOutputStream(file1);
                var nbttagcompound   = new NBTTagCompound();
                var nbttagcompound1  = new NBTTagCompound();
                nbttagcompound.setTag("Level", nbttagcompound1);
                storeChunkInCompound(chunk, world, nbttagcompound1);
                CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, fileoutputstream);
                fileoutputstream.close();
                if (file.exists())
                {
                    file.delete();
                }
                file1.renameTo(file);
                WorldInfo worldinfo1 = world.getWorldInfo();
                worldinfo1.func_22177_b(worldinfo1.func_22182_g() + file.length());
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
        }
Example #2
0
 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();
     }
 }