Java 类net.minecraft.nbt.CompressedStreamTools 实例源码

项目:ObsidianSuite    文件:ModelFileHandler.java   
public static void saveModelDataToObsidianFile(ModelObj model, File obsidianFile) 
{
    try 
    {
        NBTTagCompound nbt = model.createNBTTag();

        File nbtFile = new File(SETUP_NAME);
        CompressedStreamTools.write(nbt, nbtFile);

        FileUtils.addEntryToExistingZip(obsidianFile, nbtFile);
        nbtFile.delete();
    }
    catch(Exception e) 
    {
        System.err.println("Could not save model data for " + model.entityName);
        e.printStackTrace();
    }
}
项目:ObsidianSuite    文件:ImporterQubble.java   
private QubbleModel load(File file) throws IOException
{
    try (ZipFile zipFile = new ZipFile(file))
    {
        Enumeration<? extends ZipEntry> entries = zipFile.entries();

        while (entries.hasMoreElements())
        {
            ZipEntry entry = entries.nextElement();

            if (entry.getName().equals("model.nbt"))
            {
                NBTTagCompound compound = CompressedStreamTools.read(new DataInputStream(zipFile.getInputStream(entry)));
                return QubbleModel.deserialize(compound);
            }
        }
    }
    catch (ZipException zipException)
    {
        return this.loadLegacy(file);
    }

    return null;
}
项目:CreeperHostGui    文件:ServerListNoEdit.java   
@Override
public void saveServerList()
{
    prepare();
    super.saveServerList();
    int numOfServers = countServers();
    byte[] serverBytes = new byte[numOfServers];

    for (int i = 0; i < numOfServers; i++)
    {
        boolean editStatus = i < servers.size() && servers.get(i);
        serverBytes[i] = editStatus ? (byte) 1 : (byte) 0;
    }

    try
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setByteArray("servers", serverBytes);
        CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "mtservers.dat"));
    }
    catch (Exception exception)
    {
        //logger.error("Couldn\'t save server list", exception);
    }
}
项目:CreeperHostGui    文件:ServerListNoEdit.java   
@Override
public void saveServerList()
{
    prepare();
    super.saveServerList();
    int numOfServers = countServers();
    byte[] serverBytes = new byte[numOfServers];

    for (int i = 0; i < numOfServers; i++)
    {
        boolean editStatus = i < servers.size() && servers.get(i);
        serverBytes[i] = editStatus ? (byte) 1 : (byte) 0;
    }

    try
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setByteArray("servers", serverBytes);
        CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "mtservers.dat"));
    }
    catch (Exception exception)
    {
        //logger.error("Couldn\'t save server list", exception);
    }
}
项目:DecompiledMinecraft    文件:AnvilChunkLoader.java   
/**
 * Loads the specified(XZ) chunk into the specified world.
 */
public Chunk loadChunk(World worldIn, int x, int z) throws IOException
{
    ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z);
    NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkcoordintpair);

    if (nbttagcompound == null)
    {
        DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);

        if (datainputstream == null)
        {
            return null;
        }

        nbttagcompound = CompressedStreamTools.read(datainputstream);
    }

    return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
}
项目:DecompiledMinecraft    文件:SaveHandler.java   
/**
 * Writes the player data to disk from the specified PlayerEntityMP.
 */
public void writePlayerData(EntityPlayer player)
{
    try
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        player.writeToNBT(nbttagcompound);
        File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat.tmp");
        File file2 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
        CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1));

        if (file2.exists())
        {
            file2.delete();
        }

        file1.renameTo(file2);
    }
    catch (Exception var5)
    {
        logger.warn("Failed to save player data for " + player.getName());
    }
}
项目:DecompiledMinecraft    文件:SaveHandler.java   
/**
 * Reads the player data from disk into the specified PlayerEntityMP.
 */
public NBTTagCompound readPlayerData(EntityPlayer player)
{
    NBTTagCompound nbttagcompound = null;

    try
    {
        File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");

        if (file1.exists() && file1.isFile())
        {
            nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1));
        }
    }
    catch (Exception var4)
    {
        logger.warn("Failed to load player data for " + player.getName());
    }

    if (nbttagcompound != null)
    {
        player.readFromNBT(nbttagcompound);
    }

    return nbttagcompound;
}
项目:DecompiledMinecraft    文件:PacketBuffer.java   
/**
 * Writes a compressed NBTTagCompound to this buffer
 */
public void writeNBTTagCompoundToBuffer(NBTTagCompound nbt)
{
    if (nbt == null)
    {
        this.writeByte(0);
    }
    else
    {
        try
        {
            CompressedStreamTools.write(nbt, new ByteBufOutputStream(this));
        }
        catch (IOException ioexception)
        {
            throw new EncoderException(ioexception);
        }
    }
}
项目:DecompiledMinecraft    文件:PacketBuffer.java   
/**
 * Reads a compressed NBTTagCompound from this buffer
 */
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException
{
    int i = this.readerIndex();
    byte b0 = this.readByte();

    if (b0 == 0)
    {
        return null;
    }
    else
    {
        this.readerIndex(i);
        return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L));
    }
}
项目:DecompiledMinecraft    文件:AnvilChunkLoader.java   
/**
 * Loads the specified(XZ) chunk into the specified world.
 */
public Chunk loadChunk(World worldIn, int x, int z) throws IOException
{
    ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z);
    NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkcoordintpair);

    if (nbttagcompound == null)
    {
        DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);

        if (datainputstream == null)
        {
            return null;
        }

        nbttagcompound = CompressedStreamTools.read(datainputstream);
    }

    return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
}
项目:DecompiledMinecraft    文件:SaveFormatOld.java   
/**
 * Renames the world by storing the new name in level.dat. It does *not* rename the directory containing the world
 * data.
 */
public void renameWorld(String dirName, String newName)
{
    File file1 = new File(this.savesDirectory, dirName);

    if (file1.exists())
    {
        File file2 = new File(file1, "level.dat");

        if (file2.exists())
        {
            try
            {
                NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2));
                NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
                nbttagcompound1.setString("LevelName", newName);
                CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file2));
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
        }
    }
}
项目:DecompiledMinecraft    文件:SaveHandler.java   
/**
 * Writes the player data to disk from the specified PlayerEntityMP.
 */
public void writePlayerData(EntityPlayer player)
{
    try
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        player.writeToNBT(nbttagcompound);
        File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat.tmp");
        File file2 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
        CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1));

        if (file2.exists())
        {
            file2.delete();
        }

        file1.renameTo(file2);
    }
    catch (Exception var5)
    {
        logger.warn("Failed to save player data for " + player.getName());
    }
}
项目:DecompiledMinecraft    文件:SaveHandler.java   
/**
 * Reads the player data from disk into the specified PlayerEntityMP.
 */
public NBTTagCompound readPlayerData(EntityPlayer player)
{
    NBTTagCompound nbttagcompound = null;

    try
    {
        File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");

        if (file1.exists() && file1.isFile())
        {
            nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1));
        }
    }
    catch (Exception var4)
    {
        logger.warn("Failed to load player data for " + player.getName());
    }

    if (nbttagcompound != null)
    {
        player.readFromNBT(nbttagcompound);
    }

    return nbttagcompound;
}
项目:DecompiledMinecraft    文件:MapStorage.java   
/**
 * Saves the given MapDataBase to disk.
 */
private void saveData(WorldSavedData p_75747_1_)
{
    if (this.saveHandler != null)
    {
        try
        {
            File file1 = this.saveHandler.getMapFileFromName(p_75747_1_.mapName);

            if (file1 != null)
            {
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                p_75747_1_.writeToNBT(nbttagcompound);
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                nbttagcompound1.setTag("data", nbttagcompound);
                FileOutputStream fileoutputstream = new FileOutputStream(file1);
                CompressedStreamTools.writeCompressed(nbttagcompound1, fileoutputstream);
                fileoutputstream.close();
            }
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }
}
项目:DecompiledMinecraft    文件:PacketBuffer.java   
/**
 * Writes a compressed NBTTagCompound to this buffer
 */
public void writeNBTTagCompoundToBuffer(NBTTagCompound nbt)
{
    if (nbt == null)
    {
        this.writeByte(0);
    }
    else
    {
        try
        {
            CompressedStreamTools.write(nbt, new ByteBufOutputStream(this));
        }
        catch (IOException ioexception)
        {
            throw new EncoderException(ioexception);
        }
    }
}
项目:DecompiledMinecraft    文件:PacketBuffer.java   
/**
 * Reads a compressed NBTTagCompound from this buffer
 */
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException
{
    int i = this.readerIndex();
    byte b0 = this.readByte();

    if (b0 == 0)
    {
        return null;
    }
    else
    {
        this.readerIndex(i);
        return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L));
    }
}
项目:DecompiledMinecraft    文件:ServerList.java   
/**
 * Loads a list of servers from servers.dat, by running ServerData.getServerDataFromNBTCompound on each NBT compound
 * found in the "servers" tag list.
 */
public void loadServerList()
{
    try
    {
        this.servers.clear();
        NBTTagCompound nbttagcompound = CompressedStreamTools.read(new File(this.mc.mcDataDir, "servers.dat"));

        if (nbttagcompound == null)
        {
            return;
        }

        NBTTagList nbttaglist = nbttagcompound.getTagList("servers", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            this.servers.add(ServerData.getServerDataFromNBTCompound(nbttaglist.getCompoundTagAt(i)));
        }
    }
    catch (Exception exception)
    {
        logger.error((String)"Couldn\'t load server list", (Throwable)exception);
    }
}
项目:DecompiledMinecraft    文件:ServerList.java   
/**
 * Runs getNBTCompound on each ServerData instance, puts everything into a "servers" NBT list and writes it to
 * servers.dat.
 */
public void saveServerList()
{
    try
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (ServerData serverdata : this.servers)
        {
            nbttaglist.appendTag(serverdata.getNBTCompound());
        }

        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setTag("servers", nbttaglist);
        CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "servers.dat"));
    }
    catch (Exception exception)
    {
        logger.error((String)"Couldn\'t save server list", (Throwable)exception);
    }
}
项目:BaseClient    文件:AnvilChunkLoader.java   
/**
 * Loads the specified(XZ) chunk into the specified world.
 */
public Chunk loadChunk(World worldIn, int x, int z) throws IOException
{
    ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z);
    NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkcoordintpair);

    if (nbttagcompound == null)
    {
        DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);

        if (datainputstream == null)
        {
            return null;
        }

        nbttagcompound = CompressedStreamTools.read(datainputstream);
    }

    return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
}
项目:BaseClient    文件:SaveFormatOld.java   
/**
 * Renames the world by storing the new name in level.dat. It does *not* rename the directory containing the world
 * data.
 */
public void renameWorld(String dirName, String newName)
{
    File file1 = new File(this.savesDirectory, dirName);

    if (file1.exists())
    {
        File file2 = new File(file1, "level.dat");

        if (file2.exists())
        {
            try
            {
                NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2));
                NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
                nbttagcompound1.setString("LevelName", newName);
                CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file2));
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
        }
    }
}
项目:BaseClient    文件:SaveHandler.java   
/**
 * Writes the player data to disk from the specified PlayerEntityMP.
 */
public void writePlayerData(EntityPlayer player)
{
    try
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        player.writeToNBT(nbttagcompound);
        File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat.tmp");
        File file2 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
        CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1));

        if (file2.exists())
        {
            file2.delete();
        }

        file1.renameTo(file2);
    }
    catch (Exception var5)
    {
        logger.warn("Failed to save player data for " + player.getName());
    }
}
项目:BaseClient    文件:SaveHandler.java   
/**
 * Reads the player data from disk into the specified PlayerEntityMP.
 */
public NBTTagCompound readPlayerData(EntityPlayer player)
{
    NBTTagCompound nbttagcompound = null;

    try
    {
        File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");

        if (file1.exists() && file1.isFile())
        {
            nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1));
        }
    }
    catch (Exception var4)
    {
        logger.warn("Failed to load player data for " + player.getName());
    }

    if (nbttagcompound != null)
    {
        player.readFromNBT(nbttagcompound);
    }

    return nbttagcompound;
}
项目:BaseClient    文件:MapStorage.java   
/**
 * Saves the given MapDataBase to disk.
 */
private void saveData(WorldSavedData p_75747_1_)
{
    if (this.saveHandler != null)
    {
        try
        {
            File file1 = this.saveHandler.getMapFileFromName(p_75747_1_.mapName);

            if (file1 != null)
            {
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                p_75747_1_.writeToNBT(nbttagcompound);
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                nbttagcompound1.setTag("data", nbttagcompound);
                FileOutputStream fileoutputstream = new FileOutputStream(file1);
                CompressedStreamTools.writeCompressed(nbttagcompound1, fileoutputstream);
                fileoutputstream.close();
            }
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }
}
项目:BaseClient    文件:PacketBuffer.java   
/**
 * Writes a compressed NBTTagCompound to this buffer
 */
public void writeNBTTagCompoundToBuffer(NBTTagCompound nbt)
{
    if (nbt == null)
    {
        this.writeByte(0);
    }
    else
    {
        try
        {
            CompressedStreamTools.write(nbt, new ByteBufOutputStream(this));
        }
        catch (IOException ioexception)
        {
            throw new EncoderException(ioexception);
        }
    }
}
项目:BaseClient    文件:PacketBuffer.java   
/**
 * Reads a compressed NBTTagCompound from this buffer
 */
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException
{
    int i = this.readerIndex();
    byte b0 = this.readByte();

    if (b0 == 0)
    {
        return null;
    }
    else
    {
        this.readerIndex(i);
        return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L));
    }
}
项目:BaseClient    文件:ServerList.java   
/**
 * Loads a list of servers from servers.dat, by running ServerData.getServerDataFromNBTCompound on each NBT compound
 * found in the "servers" tag list.
 */
public void loadServerList()
{
    try
    {
        this.servers.clear();
        NBTTagCompound nbttagcompound = CompressedStreamTools.read(new File(this.mc.mcDataDir, "servers.dat"));

        if (nbttagcompound == null)
        {
            return;
        }

        NBTTagList nbttaglist = nbttagcompound.getTagList("servers", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            this.servers.add(ServerData.getServerDataFromNBTCompound(nbttaglist.getCompoundTagAt(i)));
        }
    }
    catch (Exception exception)
    {
        logger.error((String)"Couldn\'t load server list", (Throwable)exception);
    }
}
项目:BaseClient    文件:ServerList.java   
/**
 * Runs getNBTCompound on each ServerData instance, puts everything into a "servers" NBT list and writes it to
 * servers.dat.
 */
public void saveServerList()
{
    try
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (ServerData serverdata : this.servers)
        {
            nbttaglist.appendTag(serverdata.getNBTCompound());
        }

        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setTag("servers", nbttaglist);
        CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "servers.dat"));
    }
    catch (Exception exception)
    {
        logger.error((String)"Couldn\'t save server list", (Throwable)exception);
    }
}
项目:BaseClient    文件:AnvilChunkLoader.java   
/**
 * Loads the specified(XZ) chunk into the specified world.
 */
public Chunk loadChunk(World worldIn, int x, int z) throws IOException
{
    ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z);
    NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkcoordintpair);

    if (nbttagcompound == null)
    {
        DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);

        if (datainputstream == null)
        {
            return null;
        }

        nbttagcompound = CompressedStreamTools.read(datainputstream);
    }

    return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
}
项目:BaseClient    文件:SaveFormatOld.java   
/**
 * Renames the world by storing the new name in level.dat. It does *not* rename the directory containing the world
 * data.
 */
public void renameWorld(String dirName, String newName)
{
    File file1 = new File(this.savesDirectory, dirName);

    if (file1.exists())
    {
        File file2 = new File(file1, "level.dat");

        if (file2.exists())
        {
            try
            {
                NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2));
                NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
                nbttagcompound1.setString("LevelName", newName);
                CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file2));
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
        }
    }
}
项目:BaseClient    文件:SaveHandler.java   
/**
 * Writes the player data to disk from the specified PlayerEntityMP.
 */
public void writePlayerData(EntityPlayer player)
{
    try
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        player.writeToNBT(nbttagcompound);
        File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat.tmp");
        File file2 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
        CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1));

        if (file2.exists())
        {
            file2.delete();
        }

        file1.renameTo(file2);
    }
    catch (Exception var5)
    {
        logger.warn("Failed to save player data for " + player.getName());
    }
}
项目:BaseClient    文件:SaveHandler.java   
/**
 * Reads the player data from disk into the specified PlayerEntityMP.
 */
public NBTTagCompound readPlayerData(EntityPlayer player)
{
    NBTTagCompound nbttagcompound = null;

    try
    {
        File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");

        if (file1.exists() && file1.isFile())
        {
            nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1));
        }
    }
    catch (Exception var4)
    {
        logger.warn("Failed to load player data for " + player.getName());
    }

    if (nbttagcompound != null)
    {
        player.readFromNBT(nbttagcompound);
    }

    return nbttagcompound;
}
项目:BaseClient    文件:MapStorage.java   
/**
 * Saves the given MapDataBase to disk.
 */
private void saveData(WorldSavedData p_75747_1_)
{
    if (this.saveHandler != null)
    {
        try
        {
            File file1 = this.saveHandler.getMapFileFromName(p_75747_1_.mapName);

            if (file1 != null)
            {
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                p_75747_1_.writeToNBT(nbttagcompound);
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                nbttagcompound1.setTag("data", nbttagcompound);
                FileOutputStream fileoutputstream = new FileOutputStream(file1);
                CompressedStreamTools.writeCompressed(nbttagcompound1, fileoutputstream);
                fileoutputstream.close();
            }
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }
}
项目:BaseClient    文件:PacketBuffer.java   
/**
 * Writes a compressed NBTTagCompound to this buffer
 */
public void writeNBTTagCompoundToBuffer(NBTTagCompound nbt)
{
    if (nbt == null)
    {
        this.writeByte(0);
    }
    else
    {
        try
        {
            CompressedStreamTools.write(nbt, new ByteBufOutputStream(this));
        }
        catch (IOException ioexception)
        {
            throw new EncoderException(ioexception);
        }
    }
}
项目:BaseClient    文件:PacketBuffer.java   
/**
 * Reads a compressed NBTTagCompound from this buffer
 */
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException
{
    int i = this.readerIndex();
    byte b0 = this.readByte();

    if (b0 == 0)
    {
        return null;
    }
    else
    {
        this.readerIndex(i);
        return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L));
    }
}
项目:BaseClient    文件:ServerList.java   
/**
 * Loads a list of servers from servers.dat, by running ServerData.getServerDataFromNBTCompound on each NBT compound
 * found in the "servers" tag list.
 */
public void loadServerList()
{
    try
    {
        this.servers.clear();
        NBTTagCompound nbttagcompound = CompressedStreamTools.read(new File(this.mc.mcDataDir, "servers.dat"));

        if (nbttagcompound == null)
        {
            return;
        }

        NBTTagList nbttaglist = nbttagcompound.getTagList("servers", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            this.servers.add(ServerData.getServerDataFromNBTCompound(nbttaglist.getCompoundTagAt(i)));
        }
    }
    catch (Exception exception)
    {
        logger.error((String)"Couldn\'t load server list", (Throwable)exception);
    }
}
项目:BaseClient    文件:ServerList.java   
/**
 * Runs getNBTCompound on each ServerData instance, puts everything into a "servers" NBT list and writes it to
 * servers.dat.
 */
public void saveServerList()
{
    try
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (ServerData serverdata : this.servers)
        {
            nbttaglist.appendTag(serverdata.getNBTCompound());
        }

        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setTag("servers", nbttaglist);
        CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "servers.dat"));
    }
    catch (Exception exception)
    {
        logger.error((String)"Couldn\'t save server list", (Throwable)exception);
    }
}
项目:Backmemed    文件:AnvilChunkLoader.java   
@Nullable

    /**
     * Loads the specified(XZ) chunk into the specified world.
     */
    public Chunk loadChunk(World worldIn, int x, int z) throws IOException
    {
        ChunkPos chunkpos = new ChunkPos(x, z);
        NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkpos);

        if (nbttagcompound == null)
        {
            DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);

            if (datainputstream == null)
            {
                return null;
            }

            nbttagcompound = this.dataFixer.process(FixTypes.CHUNK, CompressedStreamTools.read(datainputstream));
        }

        return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
    }
项目:Backmemed    文件:SaveFormatOld.java   
/**
 * Renames the world by storing the new name in level.dat. It does *not* rename the directory containing the world
 * data.
 */
public void renameWorld(String dirName, String newName)
{
    File file1 = new File(this.savesDirectory, dirName);

    if (file1.exists())
    {
        File file2 = new File(file1, "level.dat");

        if (file2.exists())
        {
            try
            {
                NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2));
                NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
                nbttagcompound1.setString("LevelName", newName);
                CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file2));
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
        }
    }
}
项目:Backmemed    文件:SaveHandler.java   
/**
 * Writes the player data to disk from the specified PlayerEntityMP.
 */
public void writePlayerData(EntityPlayer player)
{
    try
    {
        NBTTagCompound nbttagcompound = player.writeToNBT(new NBTTagCompound());
        File file1 = new File(this.playersDirectory, player.getCachedUniqueIdString() + ".dat.tmp");
        File file2 = new File(this.playersDirectory, player.getCachedUniqueIdString() + ".dat");
        CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1));

        if (file2.exists())
        {
            file2.delete();
        }

        file1.renameTo(file2);
    }
    catch (Exception var5)
    {
        LOGGER.warn("Failed to save player data for {}", new Object[] {player.getName()});
    }
}
项目:Backmemed    文件:MapStorage.java   
/**
 * Saves the given MapDataBase to disk.
 */
private void saveData(WorldSavedData data)
{
    if (this.saveHandler != null)
    {
        try
        {
            File file1 = this.saveHandler.getMapFileFromName(data.mapName);

            if (file1 != null)
            {
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                nbttagcompound.setTag("data", data.writeToNBT(new NBTTagCompound()));
                FileOutputStream fileoutputstream = new FileOutputStream(file1);
                CompressedStreamTools.writeCompressed(nbttagcompound, fileoutputstream);
                fileoutputstream.close();
            }
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }
}