Making a mob execute a command before being unloaded

Started by bigburgerkittnt on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Making a mob execute a command before being unloaded

I am making a boss with a fail state where if the player fighting it dies, its theme stops playing and it despawns. I was able to get the rest to work by making it fail the fight if no players are in a certain radius, however, since the mob gets unloaded when the player dies and respawns far away, the effects (most importantly the music stop) do not happen until the player gets back to the boss. How can I execute the music stopping command before this? (The boss indirectly kills the player with falling blocks and other mobs, so I don't think I can use the "kills an entity" trigger) I also tried to /forceload the boss's chunks and it did not work. 

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Could you maybe have the…
Fri, 08/29/2025 - 07:06

Could you maybe have the player be more responsible for the music?

Like I don't know how you've set this up. But you could maybe set like a nbt tag or a global variable on the player (when that boss fight starts), that is checked occasionally for whether the music should play.

And then when the player respawns reset that variable/tag.