Java Code Examples for net.minecraft.entity.player.EntityPlayer.writeToNBT()

The following are Jave code examples for showing how to use writeToNBT() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: SaveHandler.java   View Source Code Vote up 6 votes
/**
 * 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());
    }
}
 
Example 2
Project: DecompiledMinecraft   File: SaveHandler.java   View Source Code Vote up 6 votes
/**
 * 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());
    }
}
 
Example 3
Project: BaseClient   File: SaveHandler.java   View Source Code Vote up 6 votes
/**
 * 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());
    }
}
 
Example 4
Project: BaseClient   File: SaveHandler.java   View Source Code Vote up 6 votes
/**
 * 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());
    }
}
 
Example 5
Project: Backmemed   File: SaveHandler.java   View Source Code Vote up 6 votes
/**
 * 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()});
    }
}
 
Example 6
Project: CustomWorldGen   File: SaveHandler.java   View Source Code Vote up 6 votes
/**
 * 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);
        net.minecraftforge.event.ForgeEventFactory.firePlayerSavingEvent(player, this.playersDirectory, player.getUniqueID().toString());
    }
    catch (Exception var5)
    {
        LOGGER.warn("Failed to save player data for {}", new Object[] {player.getName()});
    }
}