Groovy
96.8 FMNow playing 0:00 / 0:00Overnight with Ray Dawn
docs/modpack-devs.md

For modpack makers

1756 words·~8 min read

How to fit Groovy into a pack: what to switch off, what to retag, which recipes to change, and what a quest can point at. Every recipe, tag and advancement is data, so a datapack, KubeJS or CraftTweaker can change it. Songs are not data: they live in each world's library (data/groovy/songs/, CONFIG.md).

Pack check

/groovy diagnose (operators, permission level 2) shows how Groovy sits in your pack. It prints to chat and to the server log, so it works from a server console. Chat shortens a list after 12 entries ("and 8 more"); the log has every list whole. Lines that need a look are yellow in chat and WARN in the log, and the command returns how many there were.

linewhat it tells youa warning when
Content switcheshow many recipes, loot tables and advancements of any pack load only while a Groovy block is switched on (groovy:config)a file asks for a switch that doesn't exist ("flag": "radios"): it never loads, and nothing else says so
Recipesthe mod's recipes by type, its own and those a datapack or KubeJS added under groovy:a recipe takes something no item in this pack matches (an empty tag)
Tags the recipes takehow many items each tag the mod's recipes take holds here (#c:ingots/iron 3)a tag is empty; one of the mod's own tags is empty
Works withthe mods it integrates that are installed, with their versions, and those that aren'tnever
Confighow many blocks are switched on and which are off; this world's station range, mast, radio distance, song cap and Live modenever
WorldgenGroovy adds nonenever

Run it after every change to the pack's scripts and datapacks.

Config

All options are in CONFIG.md. The ones packs usually touch:

optionfilewhat for
content.<block> (station, radio, synthesizer, onAirSign, coffeeMug, ...)config/groovy-common.tomltake a block out of the pack (below)
station.baseRange, mast.rangePerSegment, mast.maxSegmentsdefaultconfigs/groovy-server.tomlhow far stations reach: 96 blocks, plus 32 per mast segment up to 8
songs.maxPerPlayerdefaultconfigs/groovy-server.tomlhow many songs each player may store in a world (256)
live.enabled, live.delayTicksdefaultconfigs/groovy-server.tomlLive mode on or off; the delay that hides network lag (10 ticks)

Switching a block off

Set its switch in config/groovy-common.toml to false, for example radio = false under [content]. The block's recipe doesn't load, it leaves the creative tab, JEI and EMI, and /groovy diagnose lists it as off. Blocks already placed stay; what they still do is in CONFIG.md.

Your own data that makes or uses that block should leave with it. Give it the same condition Groovy's recipes carry, groovy:config with the switch's name in snake case (radio, station, synthesizer, on_air_sign, broadcast_microphone, cassette_rack, monitor_speaker, studio_couch, coffee_mug, acoustic_foam, studio_rug, desk_lamp, floor_lamp):

{
  "neoforge:conditions": [
    { "type": "groovy:config", "flag": "radio" }
  ],
  "type": "minecraft:crafting_shapeless",
  "ingredients": [{ "item": "minecraft:note_block" }, { "tag": "c:ingots/iron" }, { "tag": "c:dusts/redstone" }],
  "result": { "id": "groovy:radio", "count": 1 }
}

A switch name with a typo loads nothing; /groovy diagnose names the file.

Tags

Every recipe input is a conventional c: tag where one exists, so every mod's iron, copper and quartz work: #c:ingots/iron, #c:ingots/copper, #c:nuggets/iron, #c:dusts/redstone, #c:dusts/glowstone, #c:gems/quartz, #c:strings, #c:rods/wooden, #c:bricks/normal, the #c:dyes/*, and vanilla's #minecraft:planks, #minecraft:wool and #minecraft:wool_carpets. /groovy diagnose shows what each holds in your pack.

tagholdsused for
#groovy:tapes (item)the tape and the blank tapewhat the cassette rack takes, from players and hoppers
#groovy:holds_value (block)the broadcast stationblocks that hold items; it is in #minecraft:wither_immune, #minecraft:dragon_immune and #create:non_breakable, so the Wither, the dragon and Create's drills leave them alone

Recipes

Every recipe is a plain crafting recipe with a groovy: id (groovy:radio, groovy:broadcast_station, groovy:blank_tape, ...), so it is changed like any other mod's. The exception is copying a tape: a tape and a blank tape anywhere in the grid (groovy:tape_copy, a special recipe type that JEI shows on the tape's information page). Groovy has no recipe types of its own; its one datapack registry is groovy:instrument (Instruments).

Instruments

The six pitched presets and the drum kit are entries of the datapack registry groovy:instrument: groovy:keys, groovy:bass, groovy:lead, groovy:pad, groovy:pluck, groovy:bell and groovy:kit. The server syncs the registry to every player, so everyone hears the same sound. A song names its instruments by id.

  • Retune a preset: put a file with its id's path under data/groovy/groovy/instrument/, as docs/examples/datapack does for the bass. The file replaces the whole entry, and a field you leave out takes the default below, not the preset's value: copy the preset's file from the Groovy jar (data/groovy/groovy/instrument/) and change what you need.
  • Add an instrument: any other id, data/mypack/groovy/instrument/organ.json for mypack:organ. The editor offers it after the presets on tracks of its kind. Its name comes from the lang key instrument.mypack.organ in a resource pack, else the editor shows the id. A song that names it plays the kind's fallback on a server without your datapack. Live mode plays only the seven ids above; an added instrument plays as the fallback there.
  • Your pack must sit above Groovy's data to win, as for any file. A datapack a world finds new goes on top; KubeJS's kubejs/data/groovy/groovy/instrument/ always sits above the mods (example).
  • Changes need a world restart. The registry loads when the world starts; /reload doesn't change it.
  • Bad values don't break the world. A field of the wrong type, an unknown waveform, filter mode or kit slot, or a field nobody reads is left out with a WARN line in the log and takes its default. A number outside its range is clamped to the nearest end, logged with the entry's id when the server starts. An entry that isn't a JSON object or has no kind plays the built-in sound of its id. Only a file that isn't JSON at all stops the world from loading, as for every datapack registry; the log names the file.

A pitched instrument ("kind": "pitch"). Signal path: (1 − mix) × oscillator + mix × oscillator2, then the filter, then the envelope and the gain.

fieldrangedefaultwhat it does
oscillator.wavesine, triangle, saw, square, pulse, noisesinethe main oscillator
oscillator.pulse_width0.05–0.950.5the high part of a pulse wave, for both oscillators
oscillator2.waveas abovesinethe second oscillator, silent at mix 0
oscillator2.semitones−24 to 240its interval above the first
oscillator2.cents−100 to 1000its detune
oscillator2.mix0–100 only the first oscillator, 1 only the second
envelope.attack, envelope.decay0–10 s0.005, 0.1to full level, then down to the sustain level
envelope.sustain0–11the level while the note is held
envelope.release0–2 s0.05from the note's end to silence
filter.modelow_pass, band_pass, high_passlow_passwhich output of the resonant filter
filter.cutoff20–20,000 Hz20,000the cutoff at middle C (MIDI 60)
filter.resonance0–0.900.9 rings hard
filter.key_track0–10how far the cutoff follows the pitch; 1 is an octave per octave
filter.envelope_octaves−8 to 80the cutoff starts this many octaves higher and decays back
filter.envelope_decay0.001–10 s0.1the time constant of that decay
pitch_envelope.semitones−48 to 480the pitch starts this much higher and decays back (drums)
pitch_envelope.decay0.001–2 s0.05the time constant of that decay
gain0–21the level
octave−3 to 30added to every note

A kit ("kind": "drum") has voices, an object with one key per slot: kick, low_tom, mid_tom, snare, high_tom, clap, rim, cowbell, shaker, closed_hat, open_hat, crash. Each holds the fields above plus pitch (the MIDI note its oscillators play, 0–127, fractions allowed, default 60; noise ignores it) and choke_group (0–8, default 0; a hit cuts the ringing drums of the same group on its track, as the closed hat cuts the open one). A slot left out plays the built-in drum. A drum's gate closes after attack + decay, whatever the note's length.

Advancements and quests

Quests can point at Groovy's advancements: groovy:root (a blank tape, a radio or a synthesizer picked up), groovy:label_it (a song saved onto a tape), groovy:first_light (a station placed), groovy:tuned_in (a radio tuned to a station in range) and groovy:on_air (gone live). Your own advancements can use the triggers behind them: groovy:saved_song, groovy:tuned_radio and groovy:went_live, each with only the usual player condition. Fake players earn none of them.

Demo songs and demo tapes

whatfilehow to change it
the demo songsdata//demo_songs/.json, Groovy JSONa file of the same name replaces one of ours (data/groovy/demo_songs/coffee_rings.json); a new name adds a song. A file that doesn't read is logged and left out
where tapes turn updata/groovy/loot_modifiers/demo_tapes.json, a NeoForge global loot modifier of type groovy:demo_tapesoverride the file: its conditions list the chests (neoforge:loot_table_id terms) and the chance (minecraft:random_chance, 0.2)
whether tapes turn upsongs.demoTapesInLoot in the server configfalse: no new demo tapes; tapes found before keep playing

Every world's library gets every demo song when the server starts and after /reload, so a demo tape found in a chest always plays. The synthesizer's Demo button loads the four songs in the jar, whatever the datapacks say.

KubeJS

Recipes and tags work like any other mod's. Turn a recipe off by id (event.remove({ id: 'groovy:radio' })): a datapack file with the same id only wins when its pack sits above the mod's data. Its data/groovy/groovy/instrument/bell.json retunes the bell: KubeJS's data folder sits above every mod's, so it wins over Groovy's own file (Instruments). Groovy has no KubeJS events or bindings of its own.