Skip to content

Commit

Permalink
feat: Bring back MusicManagerMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
bconlon1 committed Sep 17, 2023
1 parent 457a024 commit 8bdd266
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.aetherteam.cumulus.mixin.mixins.client;

import com.aetherteam.cumulus.client.CumulusClient;
import net.minecraft.client.Minecraft;
import net.minecraft.client.sounds.MusicManager;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.Musics;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(MusicManager.class)
public class MusicManagerMixin {
/**
* This mixin modifies the return of {@link Minecraft#getSituationalMusic()} as it is given to the music variable in {@link MusicManager}.
* @param music The original {@link Music} variable.
* @return The modified {@link Music} variable.
*/
@ModifyVariable(method = "tick()V", at = @At(value = "STORE"))
public Music injected(Music music) {
if (music == Musics.MENU && CumulusClient.MENU_HELPER.getActiveMusic() != null) {
return CumulusClient.MENU_HELPER.getActiveMusic();
}
return music;
}
}
1 change: 1 addition & 0 deletions src/main/resources/cumulus_menus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"defaultRequire": 1
},
"client": [
"client.MusicManagerMixin",
"client.accessor.CreateWorldScreenAccessor",
"client.accessor.RealmsPlayerScreenAccessor",
"client.accessor.ScreenAccessor",
Expand Down

0 comments on commit 8bdd266

Please sign in to comment.