Java Code Examples for net.minecraft.entity.player.EntityPlayerMP#getUniqueID()

The following examples show how to use net.minecraft.entity.player.EntityPlayerMP#getUniqueID() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlacementProperties.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void syncCurrentlyHeldItemDataForPlayer(EntityPlayerMP player, ItemStack stack)
{
    if (stack.isEmpty() == false && stack.getItem() instanceof ItemBlockPlacementProperty)
    {
        ItemBlockPlacementProperty item = (ItemBlockPlacementProperty) stack.getItem();

        if (item.hasPlacementProperty(stack))
        {
            UUID uuid = player.getUniqueID();
            boolean nbtSensitive = item.getPlacementProperty(stack).isNBTSensitive();
            ItemType type = new ItemType(stack, nbtSensitive);
            NBTTagCompound props = this.getPropertyTag(uuid, type);

            if (props != null)
            {
                NBTTagCompound tag = new NBTTagCompound();
                tag.setString("UUID", uuid.toString());
                tag.setTag("ItemType", stack.writeToNBT(new NBTTagCompound()));
                tag.setByte("Index", (byte) this.getPropertyIndex(uuid, type));
                tag.setTag("Tag", props);

                MessageSyncNBTTag message = new MessageSyncNBTTag(uuid, MessageSyncNBTTag.Type.PLACEMENT_PROPERTIES_CURRENT, tag);
                PacketHandler.INSTANCE.sendTo(message, player);
            }
        }
    }
}
 
Example 2
Source File: PlacementProperties.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void syncAllDataForPlayer(EntityPlayerMP player)
{
    UUID uuid = player.getUniqueID();
    Map<ItemType, NBTTagCompound> playerData = this.properties.get(uuid);

    if (playerData != null)
    {
        NBTTagCompound tag = this.writeDataForPlayerToNBT(uuid, playerData);

        MessageSyncNBTTag message = new MessageSyncNBTTag(uuid, MessageSyncNBTTag.Type.PLACEMENT_PROPERTIES_FULL, tag);
        PacketHandler.INSTANCE.sendTo(message, player);
    }
}