Solved Create custom Tooltip and show it to the player

Discussion in 'Plugin Development' started by vasil7112, Mar 9, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    Hello there developers,

    I was looking for something like, but without the need of ProtocolLib.
    After a search of about one hour the only thing i could find was the PacketPlayOutSetSlot. I searched for demostrations of that packet but couldn't find any. I also noticed that i cannot add as Itemstack the Bukkit itemstack(You need to use Minecraft Itemstack).

    Do you have any idea if there is any ready api for "Popup messages" that doesn't require ProtocolLib? If not, do you know where can i find more info about PacketPlayOutSetSlot.

    Thanks alot,
    Kind regards
  2. Offline


    This might work:
    2. ItemStack is = new ItemStack(Material.STICK, 1);
    3. ItemMeta im = is.getItemMeta();
    5. // ...
    6. String normalStickName = im.getDisplayName(); int selectedSlot = player.getHeldItemSlot();
    7. im.setDisplayName(ChatColor.RED + "Popup!");
    8. player.getInvetory().update() // where update is deprecated
    10. // ...
    11. // in a scheduled task:
    12. im.setDisplayName(normalStickName);
    13. player.getInvetory().update() // where update is deprecated
  3. Offline


    No, unfortunatly this doesn't work. Although i am trying to twick the code(e.x getItemInHand e.t.c) to name that item with the specific name i want to present. Although here is the thing that would actually might be a problem. After renaming the item and updating the inventory, will also the name display automaticly update and be shown?

    Thanks for the help GameplayJDK :)

    EDIT: I believe i got it somewhat working. When i am finished i will post the code here.

    1. ItemStack is = player.getItemInHand();
    2. ItemMeta im = is.getItemMeta();
    4. String normalItemName = im.getDisplayName();
    5. //Set item
    6. im.setDisplayName(ChatColor.BOLD+""+ChatColor.RED+"ENERGY LEFT: .....");
    7. is.setItemMeta(im);
    8. player.setItemInHand(is);
    9. player.updateInventory();
    11. // Reset item
    12. im.setDisplayName(normalItemName);
    13. is.setItemMeta(im);
    14. player.setItemInHand(is);
    15. player.updateInventory();

    I would love though to learn how to use PacketPlayOutSetSlot, because this way i will probably be able to refresh the "ItemName". With the above code that refresh will work only for 1 time for about 1 second.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 7, 2016
  4. Offline


  5. Offline


  6. Offline


    I never used any library or had to code own packen sending functions.. You will have to read the doc on this, since it doesn't seem so that there are any suitable tutorials/examples out there. vasil7112
  7. Offline


    Meanwhile i am searching, could mr. @ph1ps99 give me a bit of help?

    I have a new idea that will try soon. "Change the name of the item for 1 sec, reset it for 0.1 secs, change it again for 1 sec.".
    I will try this in about 9 hours(when i am back).

    I been trying alot, and i found somewhat a way to do it. It is not the best, but it is somewhat good.
    But still, does anyone know any special packet for that or something that might help more? Is it also possible without modifing an items name? (Sending it through packet directly to the client only).

    "Changed the Title"

    After some more search i realised that this place is also called tooltip. This might help someone!:)

    I will be adding the code on as comment. If you are looking for something like that, please see the comment section on that thread!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page