Loot Table Modification (WIP)
onEvent('block.loot_tables', event => {
event.addSimpleBlock('minecraft:dirt', 'minecraft:red_sand')
})
onEvent('block.loot_tables', event => {
event.addSimpleBlock('minecraft:dirt') // To drop itself (fix broken blocks)
event.addSimpleBlock(/minecraft:.*_ore/, 'minecraft:red_sand') // To drop a different item
})
onEvent('block.loot_tables', event => {
event.build(addBlock('minecraft:dirt', table => { // Build loot table manually
table.pool(addPool(pool => {
pool.rolls = 1 // Use one of these 3 - fixed, uniform, binominalfixed
// pool.setUniformRolls(rolls = [4, 6)6] // or {min: 4, max: 6} // uniform
// pool.setBinomialRolls(rolls = {n: 4, p: 0.3)3} // binominal
pool.survivesExplosion()
pool.addItem('minecraft:dirt')
pool.addItem('minecraft:dirt', 40) // 40 = weight
pool.addItem('minecraft:dirt', 40, [4, 8]) // [4-8] = count modifier, uses same syntax as rolls
// pool.addCondition({json condition, see vanilla wiki})
// pool.addEntry({json entry, see vanilla wiki for non-items})
})
})
})
Example from FTB Stranded:Factorial: (adds 1-3 leaves dropped from all Leaves blocks, 4-8 logs from all log and wood blocks and 4-8 stone from Stone, Cobblestone, Andesite, Diorite and Granite)
onEvent('block.loot_tables', event => {
event.addBlock(/minecraft:.*_leaves/, table => {
table.pool(addPool(pool => {
pool.setUniformRolls(1, 3)
pool.survivesExplosion()
pool.addEntry({type: addItem('minecraft:item'factorial:leaf', name:1, 'ftbstranded:leaf'}[1, 3])
})
})
event.addBlock(/minecraft:.*_(log|wood)/, table => {
table.pool(addPool(pool => {
pool.setUniformRolls(4, 8)
pool.survivesExplosion()
pool.addEntry({type: addItem('minecraft:item'factorial:wood', name:1, 'ftbstranded:wood'}[4, 8])
})
})
event.addBlock([
'minecraft:stone',
'minecraft:cobblestone',
'minecraft:andesite',
'minecraft:diorite',
'minecraft:granite'
], table => {
table.pool(addPool(pool => {
pool.setUniformRolls(rolls = [4, 8)8] // Roll the pool instead of individual items
pool.survivesExplosion()
pool.addEntry({type: addItem('minecraft:item'factorial:stone', name: 'ftbstranded:stone'})1)
})
})
})
You can also modify existing loot tables to add items to them:
onEvent('block.loot_tables', event => {
event.modifyBlock('minecraft:dirt', table => {
table.addPool(pool => {
pool.survivesExplosion()
pool.addItem('minecraft:diamond') // Breaking dirt block will now also drop a diamond
})
})
})