Datapack Structure
Create the following directory layout (replacemy_loot_balls with your namespace):
pack.mcmeta for Minecraft 1.21.1 (pack_format 48):
datapacks/ directory.
Loot Ball JSON Format
Each file indata/<namespace>/loot_ball/ defines a single loot ball. The filename (without .json) becomes its ID.
Top-level fields
Sources
Thesources object contains arrays of source rules for each source type:
Each source type holds a list of source rules. Each rule defines conditions for that loot ball to appear in that context. If any rule in a source type passes all its filters, the loot ball becomes a candidate (weighted random selection).
Source Rule Filters
Every source rule is an object with aweight and optional filters. All specified filters must pass for the rule to match (AND logic between filters). Omitted filters are treated as “allow all”.
Overview
Weight
Controls the probability of this rule being selected when multiple loot balls match.Structure
Restricts spawning to inside specific structures. The position must be within a piece of the matching structure. Supports multiple input formats. Simple format — a single string (structure ID or structure tag):required flag:
Structure entry fields
If omitted, the loot ball can appear anywhere regardless of structures.
Biome
Restricts spawning to specific biomes. Supports multiple input formats. Simple format — a single string (biome ID or biome tag):required flag:
Biome entry fields
If omitted entirely, the loot ball can appear in any biome.
Dimension
Restricts spawning to one or more dimensions.An empty list (or omitted field) means the rule passes in any dimension.
Block
Restricts spawning based on the block at the spawn position and the block directly below it. Both fields use block tags.If omitted, any block combination is allowed.
Fluid
Restricts spawning to positions containing a specific fluid (e.g. for underwater loot balls).If omitted, any fluid is allowed.
Position
Restricts spawning to specific coordinate ranges. Each axis uses a min/max range.Omitted axes allow any value for that coordinate.
Light
Spawning only. Restricts spawning based on light levels at the position.Time
Restricts spawning based on in-game time. Uses modular arithmetic to cycle within a period.Weather
Restricts spawning to specific weather conditions. Each weather type can be enabled or disabled independently.All three default to
true — if omitted, any weather is allowed.Date
Restricts spawning to a real-world calendar date range. Uses the server’s system clock.Poké Rod
Fishing only. Restricts the rule to specific Cobblemon fishing rods.Variants
Variants allow a single loot ball to have multiple flavors. Each variant can override the display name, loot table, and texture. Thevariants field is a map where keys are variant IDs (strings) and values are variant objects:
Loot Tables
Loot tables use the standard Minecraft loot table format. Place them atdata/<namespace>/loot_table/loot_ball/<name>.json.
Example Datapack
A working example datapack is included in the mod’s repository here:datapacks/ directory to test.
Where to Look in the Mod Sources (Advanced)
This guide was created with the assistance of AI tools. There may be some errors or inaccuracies.
