Bag Types - SilentChaos512/Treasure-Bags GitHub Wiki
Bag types are treasure bag variants. They are defined by JSON files. You can any number of bag types across any number of data packs. This defines the properties of the bag.
Bag type files should be placed in data/*/treasurebags_types
, where *
is your data pack's namespace. No further action is needed to register bag types, just make sure they are in the right folder. You also do not need to restart your game for this. You can either reload your world, or just use the /reload
command.
If you are not familiar with creating data packs, read about them here.
Bag Type ID
You will need to know the bag type ID in some cases, such as when writing loot tables to drop bags. In general, if you have a file located at data/namespace/treasurebags_types/file.json
, the ID would be namespace:file
. You could organize bag types in additional folders, which would become part of the ID (i.e. namespace:folder/file
). For simplicity, just put everything in one folder.
JSON Format
group
(string) - A group identifier for the bag type. Can be any string. The mod's config file allows entire groups to be easily disabled. All built-in bag types are in the "default" and "example" groups, so avoid assigning those to your bags. The "example" group is disabled by default.displayName
(text component object) - The name of the item (typically{"text": "My Bag's Name"}
)lootTable
(string) - The ID of the loot table the bag usesrarity
(string) - The rarity of the bag, which affects drop chances and name color (string property, typically: common, uncommon, rare, epic)dropsFromGroups
(array) - List of "entity groups" (peaceful, hostile, boss, player) the bag may drop frombagColor
(string) - The main color of the bag (see color notes)bagOverlayColor
(string) - The color of the design on the bag (see color notes)bagStringColor
(string) - The color of the drawstring on the bag (see color notes)
Colors
The color properties can be hex codes or CSS color names. For hex codes, the "#" symbol is optional. For CSS color names, use only letters, no spaces, case-insensitive (example: "aliceblue"). This behavior is universal across all my mods (1.13.2+).
An Example
...is worth a thousand words.
{
"group": "my_bag_group",
"displayName": {
"text": "My Custom Bag"
},
"lootTable": "mydatapack:my_loot_table",
"rarity": "common",
"bagColor": "#556B2F",
"bagOverlayColor": "#D3D3D3",
"bagStringColor": "#808080",
"dropsFromGroups": [
"peaceful",
"hostile",
"boss",
"player"
]
}