Skip to content

Chest Loot

The following examples use native KubeJS to modify chest loot generation.

Basic Syntax

Override Vanilla Chest Loot

In this example, the original End City chest loot is overridden to generate only glass and glass bottles.

js
ServerEvents.chestLootTables(event=>{
    event.addChest("minecraft:end_city_treasure",loot=>{
        loot.addPool(pool=>{
            pool.addItem("glass")
            pool.addItem("glass_bottle")
            pool.rolls = 3
            console.log(pool.conditions);
        })
    })
})

The first parameter of addChest() is the chest loot table id to override ().

If you do not want to override and instead want to add on top of existing loot, use modify() with the same parameters as addChest().

To override existing loot, define items in the pool and their .

If you want items to generate only under certain conditions, use and .

Add a New Chest Loot Table

Adding a new loot table uses the same pattern as overriding a vanilla one.

js
ServerEvents.chestLootTables(event=>{
    event.addChest("meng:chest_loot",loot=>{
        loot.addPool(pool=>{
            pool.addItem("glass")
            pool.addItem("glass_bottle")
            pool.rolls = 3
            console.log(pool.conditions);
        })
    })
})

Here we created a custom loot table with id meng:chest_loot.

You can use this command in-game to generate a chest that uses this loot table:

/setblock ~ ~ ~ chest{LootTable:"meng:chests/chest_loot"}

If you want your custom loot table to appear naturally in world generation, you need to place it via world generation events.