Wiki 9Minecraft Wiki 9Minecraft

Dropping Bags

Java EditionModGuides 5FAQ 10Related mods 48
DownloadTreasure Bags Mod

Get the files on 9Minecraft

Rarity and Entity Groups

In version 1.3.0 and higher, all bags will drop from different types of entities (mobs) based on their rarity. Each group has a loot table, which you can override to customize drop rates.

Entity group loot tables are found here: 1.16.x

Loot Function

For more control, there is a loot function which will set the bag type (as all bags are a single item). You must use this function to get the correct bag type. The function name is treasurebags:set_bag_type and it has one property, type, which is the bag type ID. See the example below.

An Example

This particular file (which is the bat loot table) has a single pool with one entry, which has a 10% drop rate with a 2.5% bonus per looting level, as well as requiring a player kill. You can of course omit these conditions if you like. You would probably want a much lower drop rate for most bags as well, maybe 1~5%.

Note that if you have more than one treasure bag entry in a pool, you need to include the entryName property with a unique value for each entry. This is needed anytime you have multiple entries of the same item.

For the bag type, this should look like your_namespace:bag_type. In this example, the bag type file is located at data/chaos_loot/treasurebags/bag_types/bat.json, which translates to a bag type ID of chaos_loot:bat.

Converting JSON file name to bag type ID:
data/namespace/treasurebags/bag_types/file.json => namespace:file

{
    "pools": [
        {
            "name": "treasure_bags",
            "rolls": 1,
            "entries": [
                {
                    "entryName": "bat_bag",
                    "type": "item",
                    "name": "treasurebags:treasure_bag",
                    "weight": 1,
                    "functions": [
                        {
                            "function": "treasurebags:set_bag_type",
                            "type": "chaos_loot:bat"
                        }
                    ]
                }
            ],
            "conditions": [
                {
                    "condition": "killed_by_player"
                },
                {
                    "condition": "random_chance_with_looting",
                    "chance": 0.1,
                    "looting_multiplier": 0.025
                }
            ]
        }
    ]
}