The method .isFromMythicSpawner() in MythicMobSpawnEvent is always false
Summary
When the event MythicMobSpawnEvent
is fired, even if this is caused by a mythic spawner, the method isFromMythicSpawner()
never returns true and you cannot get the spawner in any way.
What I figured is that the "spawner" of the spawned ActiveMob gets set after a 1 tick delay, which pretty much is the cause of this error.
Getting the spawner from the ActiveMob with a 1 tick delay works, but since I need to cancel the event based on some conditions, it has no use for me.
This was tested with both 5.0.4
and 5.0.5
on a 1.17.1 server both on paper and spigot.
Steps to reproduce
- Make a spawner in a server
- Listen to the
MythicMobSpawnEvent
- Check if the spawned mob has a spawner
- Check it again 1 tick later
- ?????
Current behavior
ActiveMob has its spawner set after a 1 tick delay.
Intended correct behavior
ActiveMob should have its spawner set when the instance is created. Not with a delay.
Code snippet on how to reproduce
@EventHandler
public void mobSpawn(MythicMobSpawnEvent e){
Bukkit.getLogger().info("Spawned mob has a spawner: " + (e.getMob().getSpawner() != null)); // prints false
Bukkit.getScheduler().runTaskLater(Plugins.CORE, new Runnable() {
@Override
public void run() {
Bukkit.getLogger().info("Spawned mob has a spawner 1 tick later: " + (e.getMob().getSpawner() != null)); // prints true
}
}, 1);
}
Proposed fixes
Set the spawner of ActiveMob when the instance is created and not with a delay.