Advertisement
Arctic_Wolfy

UUID Set and Retrieve

Mar 7th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. //UUID Set
  2. public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target) {
  3.     if (target instanceof EntityWorker && !playerIn.worldObj.isRemote){
  4.         NBTTagCompound tag = new NBTTagCompound();
  5.         UUID id = target.getPersistentID();
  6.         playerIn.addChatComponentMessage(new ChatComponentText("ID: " + id));
  7.         tag.setString("id",id.toString());
  8.         stack.setTagCompound(tag);
  9.     }
  10.     return super.itemInteractionForEntity(stack, playerIn, target);
  11. }
  12.  
  13. //UUID Retrieved
  14. public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
  15.     if (player.isSneaking()) {
  16.         // ...
  17.     } else {
  18.         NBTTagCompound tag = stack.getTagCompound();
  19.         if (tag!=null){
  20.             if (tag.hasKey("id")) {
  21.                 String idStr = tag.getString("id");
  22.                 UUID id = UUID.fromString(idStr);
  23.                 // doesn't even get here ...
  24.             }
  25.         }
  26.     }
  27.     return super.onItemUseFirst(stack, player, world, pos, side, hitX, hitY, hitZ);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement