Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
- {
- if (world.isRemote)
- {
- if (stack.stackTagCompound != null)
- {
- if (!isOnCooldown())
- {
- lastUsed = System.currentTimeMillis();
- if (player.isSneaking())
- {
- int[] homePos =
- { (int) player.posX, (int) player.posY, (int) player.posZ };
- stack.stackTagCompound.setIntArray("magicmirrorHomePos", homePos);
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + "Home set to your current location."));
- return stack;
- } else
- {
- if (!stack.stackTagCompound.hasKey("magicmirrorHomePos"))
- {
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_RED + "No home found. [Shift + Right Click] to set your home."));
- return stack;
- }
- int[] homePos = stack.stackTagCompound.getIntArray("magicmirrorHomePos");
- Vector3f pos = new Vector3f(homePos[0], homePos[1], homePos[2]);
- player.setPositionAndUpdate(pos.x, pos.y, pos.z);
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + "Teleported to (" + pos.x + ", " + pos.y + ", " + pos.z + ")."));
- playMirrorSound(world, pos);
- stack.damageItem(1, player);
- return stack;
- }
- }
- }
- }
- return stack;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement