getMetadata help

Discussion in 'Spigot Help' started by DenDennisCool, Jul 8, 2021.

  1. I need some help with getting metadata!
    Code (Java):

       @EventHandler
        public void mount(EntityMountEvent e) {
            Bukkit.broadcastMessage(e.getEntity().getMetadata("0x02").toString());
        }
     
    The server otuputs "[]"
    I have tried different things instead of 0x02, I am using that because of this wiki link:
    https://wiki.vg/Entity_metadata#Abstract_Horse
    Maybe I'm doing it all wrong? What im trying to get, is the server to output if the horse "tamed state" is true or false. If i can get that I will set the horse to insta tame which I can do myself, but I just need to know about metadata.
     
  2. I've tried the following which Didn't work:
    Code (Java):

            Horse horse = (Horse) e.getEntity();
            horse.setTamed(true);
     
    EDIT: I just found out that the Entity is actually the player mounting the horse using this
    Bukkit.broadcastMessage(e.getEntityType().toString());