stewbeet.plugins.datapack.loot_tables
The datapack.loot_tables plugin automatically generates loot tables for all custom items
defined in the project definitions. It creates individual loot tables for each item with proper
components, handles external items, supports crafting recipe variants, and generates
convenient give-all commands for testing purposes.
Required: Your definition plugin (see definitions_setup.md for details)
Optional: External item definitions (Mem.external_definitions)
Some Features Showcase
Complete file tree (i/*, recipes/*, external/*):
Function to give all items (comfortably stored in named chests):
Source Code: stewbeet/plugins/datapack/loot_tables/__init__.py
What it does
- Generates individual loot tables for each custom item
- Applies proper item components and metadata
- Handles external items from other namespaces
- Creates variant loot tables for different crafting result counts
- Generates special loot tables for manual items
- Creates convenient give-all commands with organized chest distribution
Configuration
Basic Example Configuration
id: "your_namespace"
pipeline:
- ...
- src.setup_definitions # Load item definitions into memory
- ...
- stewbeet.plugins.datapack.loot_tables # < This plugin
- ...
# Requires source_lore to be set in meta.stewbeet section
meta:
stewbeet:
source_lore: "" # Required for chest lore generationConfiguration Options
| Option | Type | Default | Description |
|---|---|---|---|
source_lore | TextComponent | Required | Source lore text component used for give-all chest lore |
definitions | object | Required | Item definitions to generate loot tables for |
external_definitions | object | Optional | External item definitions from other namespaces |
result_of_crafting | array | Optional | Crafting recipes with different result counts |
Features
Individual Item Loot Tables
Generates dedicated loot tables for each item in definitions:
- β Single item entry with proper ID reference
- π§© Automatic component application for all non-excluded properties
- π Organized under
i/{item_name}namespace structure - π§ Proper JSON encoding with configurable max depth
External Item Support
Handles items from external namespaces and dependencies:
- π Namespace separation and proper file organization
- π Storage under
external/{namespace}/{item}structure - π Same component processing as regular items
- π Integration with external definitions system
Crafting Recipe Variants
Creates specialized loot tables for different crafting result counts:
- π’ Automatic detection of
result_of_craftingwith varying counts - π Generation of
i/{item}_x{count}loot table variants - π References to main item loot table with count modifications
- β‘ Optimized for recipe systems that need specific quantities
Manual Item Handling
Special loot table generation for manual items:
- π Dedicated manual loot table creation
- π Reference to main manual item loot table
- π Special naming convention with project namespace
Give-All Command Generation
Creates convenient testing commands with organized chest distribution:
- π¦ Automatic chest organization (27 items per chest)
- π·οΈ Custom chest names with numbering (e.g., "Chest [1/3]")
- β¨ Source lore application to all chests
- π§Ή Component cleanup excluding non-component data
- π Optimal distribution across multiple chests when needed
Next steps
- Defining items and blocks: where the items this plugin reads are declared.
- All plugins: the rest of the pipeline, in the order it runs.
- Configuring the build: enabling, ordering and configuring plugins.