Solved New method for Hotbar Messages (1.12)?

Discussion in 'Plugin Development' started by mine2012craft, Jun 15, 2017.

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

    mine2012craft

    Hello,

    So ever since 1.12 came out, my usual method of sending hotbar messages was sadly removed.

    The method I used to use was this:

    Code:
      IChatBaseComponent barmsg = ChatSerializer.a("{\"text\": \"" + "Test message" + "\"}");
        PacketPlayOutChat bar = new PacketPlayOutChat(barmsg, (byte) 2);
        ((CraftPlayer) p).getHandle().playerConnection.sendPacket(bar);
    Now, the new "PacketPlayOutChat" no longer has at byte variable attached to it, making only send normal messages through the regular chat, not the hotbar.

    Using hotbar messages has always been very important to me, as since I am using spells that have cooldowns, the Hotbar Messages show the cooldown timer left on the spell.

    Is there another method I could use, or a newer method that has been implemented? If so please notify me as soon as possible.

    Thank you,
    WarlordWeaponry
     
  2. @mine2012craft
    The same method still works, they've just added an Enum. If you change
    Code:java
    1. PacketPlayOutChat bar = new PacketPlayOutChat(barmsg, (byte) 2);
    to
    Code:java
    1. PacketPlayOutChat bar = new PacketPlayOutChat(barmsg, ChatMessageType.GAME_INFO);
    Everything should work just fine.
     
    IntoTheLight likes this.
  3. Offline

    mine2012craft

    Huh, maybe I should've read over the API first... Thank you very much! Works like it had before.
     
  4. @mine2012craft
    It's not really an API, it's the obfuscated minecraft internals :p

    Just a heads up, this is version dependent, so if you don't use reflection to make it semi-independent, this will break with every update.
     
Thread Status:
Not open for further replies.

Share This Page