#Lootjs examples for mining blocks
9 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
LootJS.modifiers(event => {
const LootOre = [
['kubejs:debris_cluster','minecraft:netherite_scrap']
]
LootOre.forEach(([ore,material]) => {
const WhenFortune = LootEntry.of(material).applyOreBonus("minecraft:fortune")
.when(c => c.matchMainHand(ItemFilter.hasEnchantment("minecraft:fortune")))
const WhenSilkTouch = LootEntry.of(ore)
.when(c => c.matchMainHand(ItemFilter.hasEnchantment("minecraft:silk_touch")))
event.addBlockModifier(ore)
.removeLoot(Ingredient.all)
.addAlternativesLoot(WhenFortune,WhenSilkTouch,material)
})
})
Would that work if i swapped debris cluster with minecraft:calcite? Then the netherite scrap with the item i want to drop when not silk touched and itd drop calcite when silk touched
Yeah, ['kubejs:debris_cluster','minecraft:netherite_scrap'] is just an example. You can add more arrays to LootOre using the format [the block mined, the item to drop without silk touch]. You can also just remove the fortune logic if you don't need it.
You can even skip the whole loop and just write this directly, replacing ore and material with the actual IDs:
LootJS.modifiers(event => {
const WhenSilkTouch = LootEntry.of(ore)
.when(c => c.matchMainHand(ItemFilter.hasEnchantment("minecraft:silk_touch")))
event.addBlockModifier(ore)
.removeLoot(Ingredient.all)
.addAlternativesLoot(WhenSilkTouch, material)
})
The most important part is the order inside .addAlternativesLoot(WhenSilkTouch, material). It executes from left to right, so if the first condition is met, it will always drop that first reward and ignore the rest.
If this worked can you please close the ticket, thanks!
Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue!
This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.
Do you have any other questions regarding your issue? Feel free to ask!
Note: You should create a new post for unrelated issues.
Oh yeah, thank you