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

The following are Jave code examples for showing how to use getCachedUniqueIdString() 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: 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 2
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()});
    }
}
 
Example 3
Project: Backmemed   File: SaveHandler.java   View Source Code Vote up 5 votes
@Nullable

    /**
     * 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.getCachedUniqueIdString() + ".dat");

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

        if (nbttagcompound != null)
        {
            player.readFromNBT(this.dataFixer.process(FixTypes.PLAYER, nbttagcompound));
        }

        return nbttagcompound;
    }
 
Example 4
Project: CustomWorldGen   File: SaveHandler.java   View Source Code Vote up 5 votes
/**
 * 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.getCachedUniqueIdString() + ".dat");

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

    if (nbttagcompound != null)
    {
        player.readFromNBT(this.dataFixer.process(FixTypes.PLAYER, nbttagcompound));
    }

    net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(player, playersDirectory, player.getUniqueID().toString());
    return nbttagcompound;
}