Datapack presets
Predicate preset for conditional loot
Predicate preset for conditional loot is now a complete Data Pack workflow instead of a templated command note. Use this preset when a loot table, advancement, or function should check a condition without duplicating the same JSON everywhere. Predicates make conditional datapack logic easier to reuse because the named file becomes the shared rule. The article keeps the setup fields, output review, Project placement, and result capture together so the command is easy to audit before it becomes part of a map setup, event trigger, or reusable command pack. The workbench review should keep predicate type, target item or entity condition, namespace, path, and generated JSON together. That gives creators a clean checkpoint before the predicate is referenced by loot tables or execute-style function logic.
Preset result
A predicate resource that can gate loot or function logic behind a held trial key.
Output
Conditional loot predicate JSON
data/nbtforge/predicate/has_trial_key.json
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:tripwire_hook"
]
}
}Preset screenshot
Build the preset
- Open the Data Pack workbench.
- Choose Predicate as the generator.
- Set namespace and resource path for the reusable condition.
- Choose a predicate type such as `match_tool`, `entity_properties`, or `random_chance`.
- Fill the item, entity, chance, or block field that the predicate uses.
- Review the JSON and copy the resource path.
- Reference the predicate from a loot table or function before testing.
Why this Data Pack preset belongs in Project
Use this preset when a loot table, advancement, or function should check a condition without duplicating the same JSON everywhere. Predicates make conditional datapack logic easier to reuse because the named file becomes the shared rule.
The workbench review should keep predicate type, target item or entity condition, namespace, path, and generated JSON together. That gives creators a clean checkpoint before the predicate is referenced by loot tables or execute-style function logic. A copied command is only useful when the surrounding assumptions are visible: selector scope, world state, order inside the pack, and the exact output that will be pasted into Minecraft. Treat this preset as a checkpoint where those details can be reviewed before the command leaves NBTForge.
The gallery is structured around that review. The first shot shows the workbench state, the second shot calls out the field or companion module that changes player-facing behavior, and the output shot keeps the command or command pair visible. When the preset has a visible result, the in-game capture confirms the same idea in a restored test world rather than relying on a generic overlay.
Testing and scope checks
A predicate file does nothing by itself. It must be referenced by a loot table condition, advancement condition, or command/function path that knows when to evaluate it.
Run the first smoke test with a narrow selector and a clean world state. Environment, utility, routing, and feedback commands can look harmless, but they often affect every player or the whole world. Confirm the command changes only the intended state, then save the exact output beside the setup or follow-up lines that explain why it exists.
If the command becomes part of a function file or command-block chain, test the copied artifact, not only the live workbench state. That catches stale selectors, wrong command order, missing setup lines, and effects that only appeared to work because a previous test left state behind.
- Keep selectors narrow until the full pack is reviewed.
- Place world setup before encounter-specific overrides.
- Save feedback commands next to the state change that triggers them.
Where to go next
After the predicate is saved, attach it to the loot table or reward function that uses the condition.
For practical uses, pair it with the chest loot dungeon preset or recipe custom crafting preset.
FAQ
Can I paste this Data Pack command into chat?
Usually yes for a one-command smoke test if the selector is safe and the line is short. For repeatable map behavior, save it to Project and copy the ordered pack or function-style output.
Why is this gallery UI-only?
This preset produces JSON, project organization, or review workflow rather than a visible in-world object. The useful proof is the workbench state, output, and Project placement.
What should I check before sharing this preset?
Check selector scope, command order, target version, and whether the command belongs in setup, encounter logic, feedback, or cleanup. Those categories decide where it should sit in a Project pack.
Open this workflow
Start from the related Data Pack workbench, then adjust the preset fields for your world.