Esempio n. 1
0
        public virtual void func_22094_a(WorldInfo worldinfo)
        {
            NBTTagCompound nbttagcompound  = worldinfo.func_22185_a();
            var            nbttagcompound1 = new NBTTagCompound();

            nbttagcompound1.setTag("Data", nbttagcompound);
            try
            {
                var file  = new File(field_22099_b, "level.dat_new");
                var file1 = new File(field_22099_b, "level.dat_old");
                var file2 = new File(field_22099_b, "level.dat");
                CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound1, new FileOutputStream(file));
                if (file1.exists())
                {
                    file1.delete();
                }
                file2.renameTo(file1);
                if (file2.exists())
                {
                    file2.delete();
                }
                file.renameTo(file2);
                if (file.exists())
                {
                    file.delete();
                }
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
        }
Esempio n. 2
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();
            }
        }
Esempio n. 3
0
        public WorldInfo func_22103_b(string s)
        {
            var file = new File(field_22106_a, s);

            if (!file.exists())
            {
                return(null);
            }
            var file1 = new File(file, "level.dat");

            if (file1.exists())
            {
                try
                {
                    NBTTagCompound nbttagcompound  = CompressedStreamTools.func_770_a(new FileInputStream(file1));
                    NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
                    return(new WorldInfo(nbttagcompound1));
                }
                catch (Exception exception)
                {
                    exception.printStackTrace();
                }
            }
            return(null);
        }
Esempio n. 4
0
        public Chunk loadChunk(World world, int i, int j)
        {
            File file = chunkFileForXZ(i, j);

            if (file != null && file.exists())
            {
                try
                {
                    var            fileinputstream = new FileInputStream(file);
                    NBTTagCompound nbttagcompound  = CompressedStreamTools.func_770_a(fileinputstream);
                    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 = 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 = loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
                    }
                    return(chunk);
                }
                catch (Exception exception)
                {
                    exception.printStackTrace();
                }
            }
            return(null);
        }
Esempio n. 5
0
        public virtual WorldInfo func_22096_c()
        {
            var file = new File(field_22099_b, "level.dat");

            if (file.exists())
            {
                try
                {
                    NBTTagCompound nbttagcompound  = CompressedStreamTools.func_770_a(new FileInputStream(file));
                    NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
                    return(new WorldInfo(nbttagcompound1));
                }
                catch (Exception exception)
                {
                    exception.printStackTrace();
                }
            }
            return(null);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
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();
     }
 }
Esempio n. 8
0
 public virtual void readPlayerData(EntityPlayer entityplayer)
 {
     try
     {
         var file = new File(worldFile,
                             (new StringBuilder()).append(entityplayer.username).append(".dat").toString());
         if (file.exists())
         {
             NBTTagCompound nbttagcompound = CompressedStreamTools.func_770_a(new FileInputStream(file));
             if (nbttagcompound != null)
             {
                 entityplayer.readFromNBT(nbttagcompound);
             }
         }
     }
     catch (Exception)
     {
         logger.warning(
             (new StringBuilder()).append("Failed to load player data for ").append(entityplayer.username).
             toString());
     }
 }
Esempio n. 9
0
 public virtual void writePlayerData(EntityPlayer entityplayer)
 {
     try
     {
         var nbttagcompound = new NBTTagCompound();
         entityplayer.writeToNBT(nbttagcompound);
         var file  = new File(worldFile, "_tmp_.dat");
         var file1 = new File(worldFile,
                              (new StringBuilder()).append(entityplayer.username).append(".dat").toString());
         CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, new FileOutputStream(file));
         if (file1.exists())
         {
             file1.delete();
         }
         file.renameTo(file1);
     }
     catch (Exception)
     {
         logger.warning(
             (new StringBuilder()).append("Failed to save player data for ").append(entityplayer.username).
             toString());
     }
 }