Jump to content

[1.17.1] Synchronized Boss Music


uSkizzik

Recommended Posts

Hello! As some of my previous topics may suggest, I'm working on a boss and I'm almost done with it.
Currently, I need a way to loop a sound file over and over again while the boss is alive. I also need this music to be synchronized between all players and I need it to play only when the players see the boss in render distance.
Minecarts seem to be a good example for looped sound files, the end music seems to also be synchronized between players (I tested it out but I'm not 100% sure.) and also the vanilla Wither already has render distance-related functions (Darkened Sky, Boss Bar).
Any ideas about how exactly I would go about combining these different sound classes and making my boss music?

Link to comment
Share on other sites

3 minutes ago, Luis_ST said:

this is the forge doc about Sounds, no idea if this is helpful in your case,
i have never used Sounds yet

My issue isn't playing sounds, I already have that figured out. My issue is that I have no idea about how to loop the music properly and have it synchronized across all players who see the boss.
I'll look deeper into vanilla code and try using my brain to figure it out. Any help is still appreciated.

Link to comment
Share on other sites

Alright, I have no idea of how to actually do this.
Vanilla seems to have a Musics class for the different music events.
The issue is that all music in the game is handled trough the Minecraft class. It uses this method:

   public Music getSituationalMusic() {
      if (this.screen instanceof WinScreen) {
         return Musics.CREDITS;
      } else if (this.player != null) {
         if (this.player.level.dimension() == Level.END) {
            return this.gui.getBossOverlay().shouldPlayMusic() ? Musics.END_BOSS : Musics.END;
         } else {
            Biome.BiomeCategory biome$biomecategory = this.player.level.getBiome(this.player.blockPosition()).getBiomeCategory();
            if (!this.musicManager.isPlayingMusic(Musics.UNDER_WATER) && (!this.player.isUnderWater() || biome$biomecategory != Biome.BiomeCategory.OCEAN && biome$biomecategory != Biome.BiomeCategory.RIVER)) {
               return this.player.level.dimension() != Level.NETHER && this.player.getAbilities().instabuild && this.player.getAbilities().mayfly ? Musics.CREATIVE : this.level.getBiomeManager().getNoiseBiomeAtPosition(this.player.blockPosition()).getBackgroundMusic().orElse(Musics.GAME);
            } else {
               return Musics.UNDER_WATER;
            }
         }
      } else {
         return Musics.MENU;
      }
   }

Only way I can think of making my boss theme functional is by somehow overriding this exact method and that will not work as far as I know...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.