Skip to content

OpenBagTwo/FoxNap

Repository files navigation

Fox Nap 🦊

server + client mod mod loader: fabric lint status mod build status RPG build status supported versions Modrinth Downloads

A Survival-, Multiplayer- and Copyright-friendly mod for adding custom music to Minecraft

foxnap-banner

Requires Fabric

What is This?

FoxNap is a simple "Vanilla Plus" mod for adding custom music discs to Minecraft.

FoxNap also adds custom musical instruments that you can play like goat horns, giving you the creative freedom to stage "live music" performances.

The Armor Stand Ensemble

Motivation

I started work on this mod after being inspired to extend the SBM Jukebox mod, which brings the Bedrock music disc playlist functionality to Java. I wanted to add an outdoor concert venue to my survival world (the name FoxNap is an homage to the Wolf Trap center for the performing arts, which was a huge fixture of my childhood), but what I kept getting hung up on was how I could source and provide the music without violating copyright--forget about adding my own personal music collection, even Youtube's "Free" audio library was off-limits, as the license terms explicitly state:

You may not make available, distribute or perform the music files from this library separately from videos and other content into which you have incorporated these music files (e.g., standalone distribution of these files is not permitted).

As I saw it, there were two options for getting around this limitation (besides abandoning the project or not sharing this mod with anyone)

  1. Limit the music included with the mod to permissively-licensed (public domain, attribution or copyleft) audio
  2. Allow users to provide their own music via a config or a resource pack

In the end, I decided, why not both?

Setup and Customization

This mod comes pre-bundled with seven new music discs:

  1. "Colors," by Tobu
  2. Camille Saint-Saëns: "Danse Macabre," performed by Kevin MacLeod
  1. Nikokai Rimsky-Korsakov: "Flight of the Bumblebee" from Tsar Saltan, performed by The US Army Band

all of which are permissively licensed under the terms specified here (I am redistributing them via this repo and mod under the compatible Creative Commons Attribution-ShareAlike 4.0 License).

If this built-in playlist sounds like your jam, and you have no desire to add anything else, then congrats! This is easy! This is a Fabric mod with builds for 1.19+ and depends only on the Fabric API (that being said, I highly recommend grabbing the SBM Jukebox mod), so just download the appropriate build to your instance's mods folder, start the game, and go find a village.

But if you're interested in some customization, read on:

Manual Resource Pack Creation

FoxNap's item and sound registration structure was designed to make it as easy as possible for you to replace or add to the built-in tracks via a resource pack similar to what you'd make if you were replacing one of the vanilla discs, with the advantage that the number of discs provided by the mod is completely dynamic and can be set or changed simply by going into your instance's mod config folder, opening foxnap.yaml in any plaintext editor and changing the value of n_discs.

From there, if you're used to vanilla disc replacement resource packs, the differences will be:

  • instead of assets/minecraft, all your files should be in assets/foxnap
  • the ids of the sound files you'll be replacing (in assets/foxnap/sounds.json) will be foxnap:track_1, foxnap:track_2, etc. all the way up to the number n_discs you set in the foxnap.yaml config file stored in your instance's mod config folder.
  • to set or replace the record textures, you'll need to create files named track_1.json, track_2.json, etc. within assets/foxnap/models/item
  • when changing the names of the tracks to display, you'll need to edit assets/foxnap/lang/en_us.json and refer to the language entries as item.foxnap.track_1 / item.foxnap.track_1.desc, item.foxnap.track_2 / item.foxnap.track_2.desc, etc.

Resource Pack Generator

If manually converting mp3s and hand-editing JSON isn't your idea of a fun time, this project provides an alternative in the form of a stand-alone and portable (read: no installation or setup required) resource pack generator.

Installation

  1. Download the executable from the release page that matches your operating system and your version of the mod.
  2. Depending on your operating system and security settings, you may need to explicitly make the resource pack generator executable (on *nix systems. You can do this from a terminal by running chmod u+x /path/to/FoxNapRPG or by going into Properties in most file managers.

You can also build the generator from source.

Generating Resource Packs

Place the generator executable in an empty folder, then move any music you want to turn into records into that folder. There is no limit to the number of tracks you can include, and they do not need to be pre-converted to Ogg. The only requirement is that the files have to be decodable by ffmpeg.

Pro Tip: if your music files include metadata, the title and artist name will get automatically extracted, and any album art will be used to help generate the music disc texture.

When you're ready, simply double-click the FoxNapRPG executable. A terminal window may pop up showing progress of the resource pack creation, and before you know it you should have a new file in your folder named FoxNapRP.zip, which you can then add as a resource pack to your game. You will then need to go into your minecraft config folder and edit foxnap.yaml to raise the number of n_discs to match the ones added by the resource pack.

When playing on a server, it's the server's n_discs value that will dictate the number of tracks that are available, but it's each player's resource pack that determines which songs each track corresponds with. Explicitly:

  • if the server has a greater number of discs specified than both what's built in (seven) and what you have defined in your resource pack, some discs will show up for you with missing textures and sound files
  • if you have more discs in your resource pack than are set on the server, then not all tracks will be available in your game

Beyond the number of discs, though, there's no reason why every player can't come online with a completely custom playlist.

Advanced Options: Command-Line Options

You can also run the generator from the command-line, which will give you access to a bunch of additional customization options, such as setting the directories to search for music or the locations the generated resource pack and mod config should be saved.

For further details, run:

$ ./FoxNapRPG --help

from the folder where you saved the generator executable.

Advanced Options: Spec File

The Resource Pack Generator also allows you to finely tune the resource pack generation behavior via a configuration file. The pack generator currently supports the following formats:

  • INI (.ini, .cfg, .config, .conf, .txt)
  • JSON (.json)
  • CSV (.csv, .tsv) where each entry specifies a single track via either its full path or its file name.

For each track, you can specify:

  • num: a track number (to override the tracks bundled with the mod or just to make sure the tracks are ordered consistently)
  • description: the name to give to the track (if you don't want this read from the ID3 tag)
  • hue: the color to give to the vinyl part of the record template
  • use_album_art: whether the album art (embedded in the track tag data) for the inlay

To use a spec configuration file when running the resource pack generator, use the -s command-line flag, e.g.

$ ./FoxNapRPG -i /path/to/my/music -s track_specs.conf

Obtaining Records and More!

So now that you've registered these custom records to the game, how do you actually get them? Outside of commands (e.g. /give @s foxnap:track_1) and Creative Mode, the sole way to obtain FoxNap records is by trading with The Maestro, a new villager who has a Jukebox as a job site (note that The Maestro does not currently spawn naturally, but this feature is planned).

The Maestro

The Maestro will pay top dollar for tonewood--stripped blocks of rare wood types--goat horns and non-FoxNap records and sells, alongside your custom music discs, a wide variety of playable musical instruments (with textures adopted from the classic mxTune mod).

Contributing

Find a bug? Have a suggestion or a question? Want to contribute a new feature or enhancement? Open an issue!

Building the Mod from Source

Building the Resource Pack Generator from Source

You can also build the generator from source.

  1. Clone this repo
  2. Download or install a version of ffmpeg that can decode files from your music library and that has support for encoding using libvorbis. Put the executable (or symbolic links to the executable) in the foxnap_rpg/bin folder.
  3. Create and activate a virtual environment using python 3.10 or above
    1. If you have a conda-based environment and package manager installed on your system, such as mambaforge, you can use the project's dedicated dev/build environment, creatable from the repo root via mamba env create -f environment.yml (substitute conda for mamba as needed)
  4. From the repo's root, with your virtual environment activated, run python -m pip install .
  5. At this point, you have two options:
    1. Use FoxNap as a python package, with $ FoxNapRPG available from the command line
    2. Create a stand-alone executable using pyinstaller ( included in the conda environment). The scripts ./rpg-build.sh for *nix or .\rpg-build.bat for Windows are available for reference.

License and Acknowledgements

All code in this repository is licensed under GPLv3.

Builds of the FoxNap Resource Pack Generator (FoxNapRPG) include binaries of ffmpeg which is licensed under the GNU Lesser General Public License (LGPL) version 2.1 or later and incorporates components licensed under the GNU General Public License (GPL) version 2 or later.

All assets in this repository are distributed under the Creative Commons Attribution-ShareAlike 4.0 License unless otherwise stated.

Instrument icons are taken from the mod mxTune by @AeronicaMC.

Instrument sounds are courtesy of Philharmonia's sound sample library.

Many thanks to @FoundationGames for making the code of his awesome Sandwichable mod so easy to understand and learn from, and similarly to Modding by Kaupenjoe for his awesome and detailed tutorials on Minecraft modding, in this case his tutorial for adding a custom villager profession.

Also shouting out @Siphalor and Reddit's jSdCool for this conversation on adding non-mod external libraries to a Fabric mod. It should not have been this hard to add the SnakeYAML library to a mod.