Skip to content

Data Pack Registration

Register ammo types and gun→ammo bindings via data pack JSON. Like the framework registries: /reload hot-reloads JSON definitions, and already-issued items follow the new definitions immediately.

General Rules

  • JSON files live in data/<namespace>/modularshootammo/<registry-path>/<id>.json
  • The filename is the entry ID (without namespace); the namespace comes from the folder path
  • Omitted optional fields use the defaults noted in code
  • Both registries carry a network codec — entries sync to clients on connection (the HUD and tooltips query them)

Ammo Type JSON (ammo_types)

Path: data/<namespace>/modularshootammo/ammo_types/<ammoTypeId>.json

JSON keyTypeRequiredDefaultDescription
nameStringYesDisplay name; supports the lang: translation-key prefix
colorStringYesIdentifier color, "#RRGGBB" format (# prefix optional); falls back to white on parse failure, never crashes
itemResource locationYesAmmo item id (determines which item counts as reserve ammo in the inventory)
reserve_limitIntegerNoUnlimitedReserve cap: the usable reserve count is truncated to this value
per_shot_costIntegerNo1Ammo consumed per shot (e.g. 2 shells per shotgun blast)
reload_soundResource locationNoNoneReload sound override, takes precedence over the generic reload sounds

Example (bundled data, the pistol round bound to demo_pistol):

json
{
  "name": "lang:modularshootammo.ammo_type.pistol_ammo",
  "color": "#FFAA00",
  "item": "modularshootammo:pistol_ammo",
  "per_shot_cost": 1
}

Full example with a reserve cap and dedicated reload sound:

json
{
  "name": "lang:modularshootammo.ammo_type.sniper_ammo",
  "color": "#AA88FF",
  "item": "modularshootammo:sniper_ammo",
  "reserve_limit": 128,
  "per_shot_cost": 1,
  "reload_sound": "modularshootammo:reload_start"
}

With a lang: prefix on name, register the key in your language files; missing translations fall back to the key itself.

Gun→Ammo Binding JSON (gun_ammo_bindings)

Path: data/<namespace>/modularshootammo/gun_ammo_bindings/<gunId>.json

JSON keyTypeRequiredDescription
ammo_typeResource locationYesThe bound ammo type id (ammo_types registry)

Example:

json
{
  "ammo_type": "modularshootammo:pistol_ammo"
}

Framework-Side Items

The ammo system builds on framework registries. The bundled data (namespace modularshootammo) declares the following framework entries:

Framework registryEntriesDescription
modularshoot:traitsuses_ammoA gun enables the ammo system by declaring "uses_ammo": true
modularshoot:traitsinfinite_ammoExempts from ammo deduction when declared (HUD shows ∞)
modularshoot:statesmag_ammo (gun/int)Magazine count, default 0
modularshoot:statesreload_tick (player/int), reload_gun (player/uuid)Reload countdown and target gun
modularshoot:attribute_metamag_size, reload_timeBound to this mod's vanilla attributes (modularshootammo:mag_size / modularshootammo:reload_time); gun base values go in the stats of the guns JSON

Enabling a gun (excerpt of modularshoot:guns/demo_pistol.json):

json
{
  "stats": {
    "modularshootammo:mag_size": 12,
    "modularshootammo:reload_time": 15,
    "modularshoot:hit_damage": 6
  },
  "traits": {
    "modularshootammo:uses_ammo": true
  }
}

Full field formats live in the framework data pack docs. The exact reload/deduction behavior is implemented by this mod's AmmoService and is not detailed here.

Released under the MIT License