Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
MythicMobs MythicMobs
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 132
    • Issues 132
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • MythicCraft
  • MythicMobsMythicMobs
  • Issues
  • #830

Closed
Open
Created Jun 16, 2022 by CmJustice@CmJustice

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

  1. Make a spawner in a server
  2. Listen to the MythicMobSpawnEvent
  3. Check if the spawned mob has a spawner
  4. Check it again 1 tick later
  5. ?????

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.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking