Chest Type Loot Tables
Operating Loot Tables
- Event: ServerEvents.chestLootTables(event => {});
js
ServerEvents.chestLootTables((event) => {
// Modify original loot table
event.modify("minecraft:end_city_treasure", (loot) => {
loot.addPool((pool) => {
// Add loot
pool.addItem("minecraft:diamond");
});
});
});js
ServerEvents.chestLootTables((event) => {
// Create loot table, but since id (ResourceLocation) is the same as original, it overrides
event.addChest("minecraft:end_city_treasure", (loot) => {
loot.addPool((pool) => {
// Add loot
pool.addItem("minecraft:diamond");
});
});
});js
ServerEvents.chestLootTables((event) => {
event.addChest("minecraft:end_city_treasure", (loot) => {
loot.addPool((pool) => {
// Add loot
pool.addItem("minecraft:diamond");
// Add conditional item modifier to loot
pool.addItem("minecraft:diamond").addConditionalFunction((c) =>
c.name(Component.aqua("Test Diamond"))
);
// Add conditional item modifier to loot pool
pool.addConditionalFunction((c) =>
c.name(Component.aqua("Test Diamond"))
);
});
loot.addPool((pool) => {
pool.addItem("minecraft:diamond");
// Add predicate to loot
pool.addItem("minecraft:diamond").survivesExplosion();
// Add predicate to loot pool
pool.survivesExplosion();
});
// Add conditional item modifier to loot table
loot.addConditionalFunction((c) => c.name(Component.aqua("Test Diamond")));
});
});Available Predicates
- Predicates available in chest type loot table context.
| Predicate Type | Effect | Statement | KubeJS Native Support | Example |
|---|---|---|---|---|
| All | Evaluates a series of loot table predicates, passes if all pass. Can be called from any context. | - | ☐ | |
| Any | Evaluates a series of loot table predicates, passes if any pass. Can be called from any context. | - | ☐ | |
| Entity Properties | Checks entity in loot table context. Can be called from any context. | entityProperties(..args) | ☑ | |
| Entity Scores | Checks entity's scoreboard scores. | entityScores(..args) | ☑ | |
| Inverted (NOT) | Defines a list of predicates, passes when contained predicates don't pass. | - | ☐ | |
| Check Location | Checks current position. Requires source from loot table context to detect, always fails if not provided. | - | ☐ | |
| Random Chance | Generates random number between 0.0-1.0 and checks if less than specified value. Can be called from any context. | randomChance(..args) | ☑ | |
| Reference Predicate File | Calls predicate file and returns result. Can be called from any context. | - | ☐ | |
| Check Time | Compares current game time (more precisely, 24000 * days + time of day) with given value. Can be called from any context. | - | ☐ | |
| Check Value | Compares a number with another number or range. Can be called from any context. | - | ☐ | |
| Check Weather | Checks current game weather state. Can be called from any context. | - | ☐ |
Available Item Modifiers
- Item modifiers available in chest type loot table context.
| Item Modifier Type | Effect | Statement | KubeJS Native Support | Example |
|---|---|---|---|---|
| Copy NBT | Copies NBT from specified source to item. Only allowed value is "block_entity" | - | ☐ | |
| Random Enchant | Adds random enchantment to item. Enchantment level is also random. | enchantRandomly(..args) | ☑ | |
| Enchant With Level | Enchants item with specified enchantment level (approximately equivalent to enchanting at an enchantment table with this level). | enchantWithLevels(..args) | ☑ | |
| Set Explorer Map | Turns normal map into explorer map pointing to a structure tag. Does nothing if item is not a map. | - | ☐ | |
| Explosion Chance | If item stack is generated from block explosion, each item has 1/explosion radius probability to disappear; item stacks are divided into individual items for calculation; otherwise does nothing. | - | ☐ | |
| Fill Player Head | Sets player head to specified player's head. Does nothing if item is not player head. | - | ☐ | |
| Furnace Smelt | Converts item to its furnace-smelted counterpart. Does nothing if item is not smeltable. | furnaceSmelt() | ☑ | |
| Limit Stack Count | Limits item count. | - | ☐ | |
| Reference Item Modifier | References another item modifier. | - | ☐ | |
| Set Attributes | Adds attribute modifiers to item. | - | ☐ | |
| Set Banner Patterns | Sets pattern on banner item. Does nothing if item is not a banner. | - | ☐ | |
| Set Contents | Sets item contents. | - | ☐ | |
| Set Item Count | Sets item quantity. | count(..args) | ☑ | |
| Set Damage | Sets tool damage value. | damage(..args) | ☑ | |
| Set Enchantments | Sets item enchantments. | - | ☐ | |
| Set Instrument | Sets goat horn type. Does nothing if item is not goat horn. | - | ☐ | |
| Set Loot Table | Sets loot table for container block item. | - | ☐ | |
| Set Lore | Adds description info to item. | - | ☐ | |
| Set Name | Adds or modifies item custom name. | name(..args) | ☑ | |
| Set NBT | Sets item stack NBT data. | nbt(..args) | ☐ | |
| Set Potion | Sets potion effect tag on item. | - | ☐ | |
| Set Suspicious Stew Effect | Adds status effect to suspicious stew. | - | ☐ |