How to check a mob is MythicMob?

Discussion in 'Add-Ons, API & Compatible Plugins' started by momocraft, Sep 25, 2019.

  1. momocraft

    momocraft New Member
    Premium Supporter Supporter

    Joined:
    Sep 12, 2018
    Messages:
    4
    Likes Received:
    0
    I use three methods to check if a mob is MythicMob when it spawn, but it only show "false".
    Is there any wrong?
    This is my code. Please help me:)

    Code:
    public class EntitySpawn implements Listener {
    
        @EventHandler
        public void onSpawnMobs(CreatureSpawnEvent e) {
    
            UUID mobEntityUUID = e.getEntity().getUniqueId();
            boolean isMythicMobUUID = MythicMobs.inst().getAPIHelper().isMythicMob(mobEntityUUID);
            boolean isMythicMobEntity = MythicMobs.inst().getAPIHelper().isMythicMob(e.getEntity());
            boolean activeMobUUID = MythicMobs.inst().getMobManager().isActiveMob(mobEntityUUID);
    
        }
    }
     
    #1
  2. momocraft

    momocraft New Member
    Premium Supporter Supporter

    Joined:
    Sep 12, 2018
    Messages:
    4
    Likes Received:
    0
    I use maven and the version of plugin jar is latest dev.
    Code:
            <!--MythicMobs API-->
            <dependency>
                <groupId>io.lumine.xikage</groupId>
                <artifactId>MythicMobs</artifactId>
                <version>LATEST</version>
                <scope>provided</scope>
            </dependency>
     
    #2
  3. Roger M

    Roger M Member
    Premium Supporter Supporter Quality Assurance

    Joined:
    May 13, 2016
    Messages:
    181
    Likes Received:
    17
    The maven is super outdated to the best of my knowledge and new versions don’t use maven. You will need to manually import it.
     
    #3
  4. momocraft

    momocraft New Member
    Premium Supporter Supporter

    Joined:
    Sep 12, 2018
    Messages:
    4
    Likes Received:
    0
    I tried to put the plugin jar inside. It still get the same result.
    Besides, where can I find the API file. :(
     
    #4
  5. Roger M

    Roger M Member
    Premium Supporter Supporter Quality Assurance

    Joined:
    May 13, 2016
    Messages:
    181
    Likes Received:
    17
    Code:
    BukkitAPIHelper api = new BukkitAPIHelper();
    UUID uuid = event.getEntity().getUniqueID();
    boolean isMM = api.isMythicMob(uuid);
    It might do exactly what you are doing, I'm not sure. Also, I'm not sure if the mob gets registered as a MythicMob prior to actually spawning, which is when this code will take place.

    Edit: Actually I don't think it registers yet on this event, someone else had the same issue last week if I remember correctly. You may need to put a delay in place, depending on what you are doing. If it would suit your needs, you could use MythicMobSpawnEvent
     
    #5
    Last edited: Sep 25, 2019
  6. Tigierrei

    Tigierrei Member

    Joined:
    Aug 19, 2016
    Messages:
    32
    Likes Received:
    4
    You can listen to the MythicMobSpawnEvent and store the entity in a hashmap like Map<Entity,MythicMob>. that's not the most efficient way but it works
     
    #6

Share This Page