Skip to content

Jukebox Song Data Generation

Maksym Uimanov edited this page Feb 10, 2026 · 1 revision

Jukebox Song Data Generation

The @GenerateJukeboxSong annotation is a data generation annotation that automatically creates jukebox song definitions for Minecraft mods using the Temporal API. It eliminates the need for manual JSON configuration by generating the necessary data providers at runtime.

Responsibilities / Purpose

  • Automatic data generation: Creates jukebox song definitions without manual JSON files
  • Metadata association: Links jukebox songs to their sound events, duration, and comparator output
  • Integration with data providers: Seamlessly integrates with NeoForge's data generation system
  • Type safety: Ensures compile-time validation of jukebox song configurations

How it works

  1. Annotation processing: The annotation is processed by GenerateJukeboxSongStrategy during the data generation phase
  2. Field extraction: The strategy extracts the ResourceKey<JukeboxSong> from the annotated field
  3. Description creation: Creates a JukeboxSongDescription containing all song metadata
  4. Provider registration: Automatically registers the song with ApiJukeboxSongProvider for data generation

How to use / Configure

Apply the annotation to static fields of type ResourceKey<JukeboxSong>:

public final class ModJukeboxSongs {
    @GenerateJukeboxSong(
        soundEvent = "mymod:custom_song",
        lengthInSeconds = 180,
        comparatorOutput = 12
    )
    public static final ResourceKey<JukeboxSong> CUSTOM_SONG = 
        ResourceUtils.createKey(Registries.JUKEBOX_SONG, "custom_song");
}

Annotation parameters

  • soundEvent (String): The sound event resource location that plays when the song is in the jukebox
  • lengthInSeconds (float): Duration of the song in seconds (affects jukebox playback timing)
  • comparatorOutput (int): Redstone comparator signal strength (0-15) when the song is playing

Extension points

The annotation integrates with the Temporal API's strategy system:

  • Strategy implementation: GenerateJukeboxSongStrategy handles the processing logic
  • Provider system: Uses ApiJukeboxSongProvider for data generation
  • Transformer support: Compatible with JukeboxSongTransformer for additional processing

When to use

Use @GenerateJukeboxSong when:

  • Creating custom music discs for your mod
  • Defining jukebox songs with specific comparator outputs
  • Automating data generation for music-related content
  • Ensuring consistent song metadata across your mod

The annotation is particularly useful for mods with multiple music discs, as it centralizes song configuration and eliminates manual JSON file management.

Clone this wiki locally