tModLoader

tModLoader

58 ratings
Jukebox: Merge Music Packs
2
2
   
Award
Favorite
Favorited
Unfavorite
Mod Side: Both
tModLoader Version: 1.4.4
Language: English
File Size
Posted
Updated
128.948 KB
Nov 20 @ 8:07pm
Nov 22 @ 12:14am
5 Change Notes ( view )

Subscribe to download
Jukebox: Merge Music Packs

Description
Have you ever felt indecisive on what music pack to use? Have you ever wished you could use multiple music packs... all at the same time? Well wish no more! This mod lets you use all of your favourite music packs together with just a simple click. Load into a world and let the mod do its magic, all music packs will be used and tracks will be picked out at random depending on the biome, time, and weather. This works with music boxes too! Hence the name JukeBox...

Jukebox: Merge Music Packs is a mod that randomizes music from all enabled resource packs instead of just the top one, allowing you to use multiple music packs at once and experience all of them.



COMMANDS:

/next - plays a track at random out of your music packs (based on what biome you are in, with time and weather considered)
/song - tells you what track is currently playing in the chat, as well as what resource pack its from, who the author is, and what the track ID is.

WHAT DOES THIS DO?

In detail, this mod uses complex but lightweight systems to randomize the song that is used from your music packs that are enabled. This mod entirely bypasses the standard Terraria and tModLoader Resource Pack prioritization system, which normally loads assets only from the single, top-most enabled pack. It does this through a multi-layered approach: first, a specialized scanner accurately reads the user's config.json file to build a strict, verified list of all truly enabled music packs, ensuring disabled packs are never included.

Second, using the ModSystem.PostUpdateEverything hook, the mod intercepts the game's music selection after the vanilla biome/time/event logic decides which song ID to play. Instead of allowing the vanilla game to retrieve the single cached song for that ID, the mod selects a file at random from its indexed list of variants. Finally, it uses Reflection to manually instantiate a specialized IAudioTrack (OGG, MP3, or WAV) by creating a fresh MemoryStream of the chosen file's data. This new, random track is then injected directly into the game's live audio array, wrapped in a SafeAudioTrack class that catches critical stream/format errors, allowing the engine to skip corrupted songs without crashing the entire game.

This combination of deep system access and safety wrappers forces Terraria to play randomized music from all enabled sources.

KNOWN BUGS

- Resource packs that are disabled, but are installed, play their tracks. // Im not sure how to fix this, but i am working on it. If anyone has a fix, lmk in the comments. Fixed!
- An error message appears occasionally, upon entering a new biome or on startup of a world. // I will fix this ASAP Fixed!


Enjoy!
Texture packs used for visuals were:
UI PACK: Fancy UI by SanDragon
(top) Secrets of the Shadows Texture Pack
(below) TerraEnhanced

Resource packs used for music shown in the photo above was:
(any order obviously)
- Zelda Music by Magicalkitnip
- TLoZ: Twilight Princess Music by MadaxTheShadow

Originally posted by tModLoader RandomPackMusic:
Developed By LevitatingGT
40 Comments
LevitatingGT  [author] 22 hours ago 
@Bucketsmith your update is mostly complete, expect an update from now to next week. am working on other mods and bugfixes for this one atm.
9 Point Flower (she/it) Dec 6 @ 5:16pm 
i think its cause of the rainy and windy music tracks
9 Point Flower (she/it) Dec 6 @ 5:11pm 
sometimes it plays two songs at once, ive noticed it happening a lot when on the surface
LevitatingGT  [author] Dec 6 @ 4:01pm 
Thanks my man 👊🏻
Bucketsmith Dec 6 @ 5:52am 
You've made some really great mods mate.
I might not be using all of them but you've certainly got a creative mind and a skillset to make results!
LevitatingGT  [author] Dec 3 @ 3:53pm 
I can definitely add that @Bucketsmith ! Expect that whenever you see that this mod has updated. Will add this in the near future easily.
Bucketsmith Dec 2 @ 9:45am 
I've been enjoying the variation that this mod makes possible.
Do you think it is possible to make song selection weighted random and not true random, versus recently played tracks?
Sometimes by pure RNG it just keeps playing the same song for the same biome.
Or perhaps even a config for us to select the weight for a resource pack or songs?
Bucketsmith Nov 30 @ 12:12pm 
Okay thank you, it works well with the resource packs!
LevitatingGT  [author] Nov 30 @ 12:12pm 
id say that this mod only works with terraria music packs man
Bucketsmith Nov 30 @ 2:39am 
Resource packs from the Terraria workshop, music packs from the tModloader workshop.
There are music packs there that don't act like a resource pack. They don't show up in the resource pack list in the menu.
That is why I am wondering if they will still be picked up by your mod?
Does it only look for resource packs, or does it look for anything that presents itself as a music track?