Skip to main content
This guide explains how to create datapacks that define custom Loot Balls for Cobbleloots. It covers the JSON format, all available filter fields, and provides real-world examples.

Datapack Structure

Create the following directory layout (replace my_loot_balls with your namespace):
pack.mcmeta for Minecraft 1.21.1 (pack_format 48):
Drop the folder into your world’s datapacks/ directory.

Loot Ball JSON Format

Each file in data/<namespace>/loot_ball/ defines a single loot ball. The filename (without .json) becomes its ID.

Top-level fields


Sources

The sources 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 a weight 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.
Common loot balls use weights of 50–100, uncommon 25–50, rare 1–10.

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):
Object format — allows setting the required flag:
List format — combine multiple entries:

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):
Object format — allows setting the required flag:
List format — combine multiple entries:

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.
This example restricts the loot ball to underground locations (below Y=0).
Omitted axes allow any value for that coordinate.

Light

Spawning only. Restricts spawning based on light levels at the position.
This example spawns only in dark spooky biomes (low light).
The light filter is only evaluated for spawning rules. It is ignored in generation, fishing, and archaeology.

Time

Restricts spawning based on in-game time. Uses modular arithmetic to cycle within a period.
This example restricts the loot ball to nighttime (ticks 13000–23000 in a 24000-tick day cycle).
Minecraft day cycle reference

Weather

Restricts spawning to specific weather conditions. Each weather type can be enabled or disabled independently.
This example restricts the loot ball to rainy weather only (not thunderstorms, not clear).
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.
This example restricts the loot ball to the Halloween season (October 1 – November 1).
Year-wrapping ranges are supported. For example, { "from": "12-01", "to": "01-31" } matches December through January.

Poké Rod

Fishing only. Restricts the rule to specific Cobblemon fishing rods.
Common patternMost shipped loot balls use two fishing rules: one with a specific rod (high weight), and one without (low weight, any rod). This lets the loot ball be fished anywhere but gives a bonus when using the matching rod:
The poke_rod filter is only evaluated for fishing rules. It is ignored in other source types. If poke_rod is set but the player is not using one of the listed rods, the rule fails.

Variants

Variants allow a single loot ball to have multiple flavors. Each variant can override the display name, loot table, and texture. The variants 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 at data/<namespace>/loot_table/loot_ball/<name>.json.
You can reference shared loot tables using { "type": "minecraft:loot_table", "value": "cobbleloots:loot_ball/shared/medicine_common" } to include the mod’s built-in loot pools.
Shipped loot tables were developed using the Loot Table Editor from Misode. You can use it to generate your own loot tables, but it doesn’t support modded items ids. You have to test the generated loot tables in a datapack to ensure they work.

Example Datapack

A working example datapack is included in the mod’s repository here:
Download the folder and drop it into your world’s 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.