Skip to content

Adding a Disc

Arno Hovhannisyan edited this page May 18, 2024 · 7 revisions

Let's assume that your addon is called disco-example and the id of your new disc is new_disc. Replace these with the actual ones in the following steps.

A full example can be found in the example directory.

Audio

  1. Convert your audio to a .ogg file with one channel (mono)
  2. Place the file at assets/disco-example/sounds/new_disc.ogg

fabric.mod.json

Add the following line to the fabric.mod.json file at the root of your project. If this file doesn't already exist, create it with the following contents contents:

The duration is the length of the audio in seconds.

{
    "schemaVersion": 1,
    "id": "disco-example",
    "version": "1.0.0",
    "name": "Disco Example",
    "description": "Example Disco addon",
    "custom": {
        "disco": {
            "discs": [
+               { "id": "new_disc", "duration": 123 }
            ]
        }
    }
}

sounds.json

Add the following lines to assets/disco-example/sounds.json:

{
+   "new_disc": {
+       "category": "record",
+       "sounds": [{ "name": "disco-example:new_disc", "stream": true }]
+   }
}

Texture

Place your sprite at assets/disco-example/textures/item/new_disc.png. It can be 16x16, but any size will work.

Model

Create assets/disco-example/models/item/new_disc.json with the following contents:

{
    "parent": "item/generated",
    "textures": {
        "layer0": "disco-example:item/new_disc"
    }
}

Translations

Add the following line to assets/disco-example/lang/en_us.json:

{
+   "item.disco-example.new_disc.desc": "Artist - New Disc"
}

Make sure to add this to any other languages your addon supports

Tags

Add an entry like shown data/disco-example/tags/items/discs.json:

{
    "values": [
+       { "id": "disco-example:new_disc", "required": false }
    ]
}

And finally, ensure that data/minecraft/tags/items/music_discs.json has the following contents:

{
    "values": [
        { "id": "#disco-example:discs", "required": false }
    ]
}

Packaging

The last step is to compress these files and directories into a .jar file. You can use the following command to do so:

cd /path/to/addon/root
jar cvf disco-example.jar .

If you compress it another way, make sure that you create a META-INF/MANIFEST.MF beforehand with at least the following contents:

Manifest-Version: 1.0
Clone this wiki locally