Minecraft Discs : Dynamically-loaded Custom Music Discs From YouTube Videos

As usual, the code is on GitHub.

A while ago, I had the idea of a simple Minecraft mod which would allow the creation of custom music discs in Minecraft using YouTube as the primary way of distributing and synchronizing the actual music tracks amongst players. All of this, while allowing any player on the server to add their own favorite music tracks.

The Forge

The actual Minecraft mod is quite simple. It reads a simple JSON-formatted list of tracks, and register them as items with Forge Mod Loader, giving them a game ID. At the same time, they get an item texture assigned, which is simply one of the existing record item textures.

Building Resources

To get the music tracks to play, the mod uses a separate resource pack, built by grabbing YouTube videos, and extracting the audio using ffmpeg. I made a simple java program to parse the JSON track list and download the tracks, while creating the required directory structure for a Minecraft resource pack. At this step, track titles also get added into the game.

Keeping Clients Coherent

Since the primary use case of this mod is multiplayer gameplay, we needed a way of keeping clients coherent, while still allowing a frequent additions. I came up with a simple CRUD-style application hosted on a Heroku container, which would serve a properly formatted track list, and offer a simple form for user to add new songs, all of that using a free-tier database. The only downside to this approach is that the container shuts itself off after 30 minutes of inactivity, then requiring roughly 25 seconds to serve the next request. This causes the game client to freeze in the loading screen, while waiting for a reply. This could be easily fixed by stepping to a more premium usage tier, but the very light usage mostly makes this a non-issue.