Class SelectMusicEvent
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
Fired when the MusicManager checks what situational music should be used. This fires before the music begins playing.
If the music is set to null by a modder, it will cancel any music that was already playing.
Note that the higher priority you make your event listener, the earlier the music will be set. Because of this, if you want your music to take precedence over others (perhaps you want to have seperate nighttime music for a biome for instance) then you may want it to have a lower priority.
To make your music instantly play rather than waiting for the playing music to stop, set the music to one that is set to replace the current music.
Higher priorities would likely be better suited for biome-based or dimension-based musics, whereas lower priority is likely good for specific structures or situations.
This event is cancellable.
Cancelling the event does not prevent the music from being changed; it stops propagation to further event handlers, and uses whatever the music was set to in the event.
It is therefore preferred to call the overrideMusic(Music) helper with your music, which automatically cancels the event for you.
This event is fired on the main Forge event bus, only on the logical client.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetMusic()Returns the Music to be played, ornullif any playing music should be cancelled.Returns the original situational music that was selected.Returns the current track that theMusicManageris playing, ornullif there is none.voidoverrideMusic(@Nullable Music newMusic) Sets the music and then cancels the event so that other listeners will not be invoked.
Note that listeners usingSubscribeEvent.receiveCanceled()will still be able to override this, but by default they will notvoidChanges the situational music.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
music
-
originalMusic
-
playingMusic
-
-
Constructor Details
-
SelectMusicEvent
-
-
Method Details
-
getOriginalMusic
Returns the original situational music that was selected.- Returns:
- the original situational music that was selected
-
getPlayingMusic
Returns the current track that theMusicManageris playing, ornullif there is none.- Returns:
- the current track that the
MusicManageris playing, ornullif there is none
-
getMusic
-
setMusic
-
overrideMusic
-