Nota
A library for Fabric that provides an API for playing .nbs format files as note block sounds. This implementation is not a complete replica of the original plugin and may contain some unfinished features.
Demonstration
Development
Adding to your project
To use Nota in your project, add the Modrinth repository to your build file and the mod dependency. Replace VERSION_TAG with the current version, for example 0.1.0+1.19.
repositories {
maven {
url "https://api.modrinth.com/maven"
content { includeGroup "maven.modrinth" }
}
}
dependencies {
modImplementation include("maven.modrinth:nota:VERSION_TAG")
}
Obtaining .nbs files
- Download ready-made .nbs music files
- Convert .midi to .nbs using Note Block Studio
- Create your own composition in Note Block Studio and export it in .nbs format
Playing compositions
Before using a song in .nbs format, it must be loaded.
Song song = NBSDecoder.parse(new File("path/to/song.nbs"));
Song song2 = NBSDecoder.parse(new File("path/to/another/song.nbs"));
Playlist playlist = new Playlist(song, song2,...);
Player types
Three types of composition players are available:
- RadioSongPlayer
- PositionSongPlayer
- EntitySongPlayer
RadioSongPlayer
Plays music for all added players regardless of their location.
Song song; // Preloaded song
RadioSongPlayer rsp = new RadioSongPlayer(song); // Create RadioSongPlayer
rsp.setId(new Identifier("example:radio")); // Set unique identifier (optional)
rsp.addPlayer(player); // Add player for listening
rsp.setPlaying(true); // Start playback
PositionSongPlayer
Plays music for players within a certain radius from a specified point.
Song song; // Preloaded song
PositionSongPlayer psp = new PositionSongPlayer(song); // Create PositionSongPlayer
psp.setId(new Identifier("example:position")); // Set unique identifier (optional)
psp.setBlockPos(position); // Set playback location
psp.setDistance(16); // Set hearing radius (default: 16)
psp.addPlayer(player); // Add player for listening
psp.setPlaying(true); // Start playback
EntitySongPlayer
Plays music for players within a certain radius from a specified entity.
Song song; // Preloaded song
EntitySongPlayer esp = new EntitySongPlayer(song); // Create EntitySongPlayer
esp.setId(new Identifier("example:entity")); // Set unique identifier (optional)
esp.setEntity(entity); // Set entity for position tracking
esp.setDistance(16); // Set hearing radius (default: 16)
esp.addPlayer(player); // Add player for listening
esp.setPlaying(true); // Start playback
