Overview#
Treasure Bags is a utility-focused mod designed for modpack creators and server administrators. It provides a framework for adding custom loot bags to Minecraft using the data pack system. Unlike other loot bag mods that come with pre-defined items, Treasure Bags is a blank canvas; by default, it includes no obtainable bags except for a single 'Starting Inventory' bag.
Every aspect of a bag—its name, color, rarity, and the loot it contains—is defined in JSON files. This allows for seamless integration with other mods and custom progression systems. The mod is compatible with both Forge and NeoForge across versions 1.20.1 and 1.21.1.
Core Mechanics#
The primary item added by this mod is the Treasure Bag. While it appears as a single item in the creative menu, its properties are determined by NBT data that links it to a specific 'Bag Type' defined in a data pack.
Usage
- Opening a Bag: Hold the Treasure Bag in your main hand and Right-Click. The loot will be rolled from the associated loot table and added directly to your inventory. If your inventory is full, the items will drop at your feet.
- Bulk Opening: To save time, you can Sneak + Right-Click while holding a stack of bags. This will open the entire stack at once and deposit all resulting loot into your inventory.
- Advanced Tooltips: By enabling advanced tooltips (F3 + H), you can see the internal Bag Type ID and the specific loot table assigned to that bag. This is invaluable for debugging data pack configurations.
Creating Bag Types#
To add bags to your game, you must create a data pack. Bag types are defined in the following directory: data/<namespace>/treasure_bags/bag_types/<name>.json.
JSON Structure
A bag type file requires several key fields to define its appearance and behavior:
| Field | Type | Description |
|---|---|---|
name |
String/Object | The display name of the bag. Supports raw strings or JSON text components (for translations/colors). |
bagColor |
Hex String | The primary color of the bag texture (e.g., "0xFFFFFF"). |
bagStringColor |
Hex String | The color of the string tied around the bag (e.g., "0x000000"). |
lootTable |
Resource Location | The ID of the loot table to roll when the bag is opened. |
rarity |
String | The rarity color of the item name (common, uncommon, rare, epic). |
Example Bag Type JSON:
{
"name": "Dungeon Treasure",
"bagColor": "0x4A4A4A",
"bagStringColor": "0xFFD700",
"lootTable": "minecraft:chests/simple_dungeon",
"rarity": "rare"
}Obtaining Bags#
Since bags are not obtainable by default, they must be added to loot tables. This can be done by modifying existing vanilla loot tables or using the mod's built-in entity groups.
Entity Groups
Treasure Bags provides specialized loot tables that allow you to add drops to broad categories of mobs without editing every individual entity file. These are located at data/treasurebags/loot_tables/entity_group/.
| Group ID | Target Entities |
|---|---|
hostile |
All monsters (Zombies, Skeletons, Creepers, etc.) |
peaceful |
Passive animals (Cows, Sheep, Pigs, etc.) |
boss |
Boss mobs (Ender Dragon, Wither, etc.) |
player |
Dropped when a player is killed. |
Starting Inventory
The mod includes a special loot table: treasurebags:starting_inventory. This table is rolled exactly once when a player first joins a world. By default, it contains a single bag of type treasurebags:spawn. Modpack creators can edit this table to provide custom starter kits or multiple bags to new players.
Crafting & Recipes#
Treasure Bags adds custom recipe types to allow for the crafting of specific bag types or using bags as ingredients in other recipes.
Recipe Types
treasurebags:shaped_bag: A shaped crafting recipe that results in a specific Treasure Bag type.treasurebags:shapeless_bag: A shapeless crafting recipe that results in a specific Treasure Bag type.
Using Bags as Ingredients
You can use Treasure Bags in standard recipes by specifying the item treasurebags:treasure_bag and matching the NBT data. The mod uses a Type string tag to identify the bag. For example, a bag defined as my_mod:epic_loot would have the NBT {Type: "my_mod:epic_loot"}.
Commands#
The mod provides administrative commands to assist with testing and distribution of bags.
| Command | Description |
|---|---|
/treasurebags give <player> <bag_type> [count] |
Gives a specific bag type to a player. |
/treasurebags list |
Lists all currently loaded bag types from all active data packs. |
/treasurebags dump_types |
Exports a list of all loaded bag types to the server logs for debugging. |
Technical Details#
Data Pack Structure
To ensure your bags load correctly, follow this folder structure within your data pack:
data/<your_namespace>/treasure_bags/bag_types/(Place bag definition JSONs here)loot_tables/bags/(Recommended location for bag loot tables)
Compatibility
- JEI/REI/EMI: The mod includes plugins to show bag contents and crafting recipes in item viewers.
- Silent Lib: This mod requires the Silent Lib library mod to function correctly on all supported versions.