Advertisement
Guest User

dawdawdawdw

a guest
May 30th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1.     @Override
  2.     public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
  3.     {
  4.         if (world.isRemote)
  5.         {
  6.             if (stack.stackTagCompound != null)
  7.             {
  8.                 if (!isOnCooldown())
  9.                 {
  10.                     lastUsed = System.currentTimeMillis();
  11.  
  12.                     if (player.isSneaking())
  13.                     {
  14.  
  15.                         int[] homePos =
  16.                         { (int) player.posX, (int) player.posY, (int) player.posZ };
  17.  
  18.                         stack.stackTagCompound.setIntArray("magicmirrorHomePos", homePos);
  19.                         player.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + "Home set to your current location."));
  20.                         return stack;
  21.                     } else
  22.                     {
  23.  
  24.                         if (!stack.stackTagCompound.hasKey("magicmirrorHomePos"))
  25.                         {
  26.                             player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_RED + "No home found. [Shift + Right Click] to set your home."));
  27.                             return stack;
  28.                         }
  29.  
  30.                         int[] homePos = stack.stackTagCompound.getIntArray("magicmirrorHomePos");
  31.                         Vector3f pos = new Vector3f(homePos[0], homePos[1], homePos[2]);
  32.  
  33.                         player.setPositionAndUpdate(pos.x, pos.y, pos.z);
  34.                         player.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + "Teleported to (" + pos.x + ", " + pos.y + ", " + pos.z + ")."));
  35.                         playMirrorSound(world, pos);
  36.                         stack.damageItem(1, player);
  37.                         return stack;
  38.                     }
  39.                 }
  40.             }
  41.         }
  42.         return stack;
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement