#Loot tables per item/tier?
4 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
I had to do something similar found this thread while browsing https://github.com/KubeJS-Mods/KubeJS/issues/189
For needing a specific tool tier the easiest way is to use block tags (server_scripts):
ServerEvents.tags('block', event => {
// Remove blocks from their current tier
event.remove('minecraft:needs_iron_tool', 'minecraft:diamond_block');
// Force blocks to be mined with netherite tool to drop item
event.add('neoforge:needs_netherite_tool', 'minecraft:diamond_block');
})
For requiring a tool you can use a block event modification (startup script):
BlockEvents.modification(event => {
// Make blocks requiring to be broken by a tool for the item to drop
event.modify('minecraft:wither_skeleton_skull', block => {
block.requiresTool = true;
});
});
For your pebble things it gets more tricky, one way is to manually modify the loot tables using the LootJS addon.
If you want some examples of what a block loot table looks like to figure out how to implement your own a nice ressource is https://misode.github.io/loot-table here is the entry for the brown mushroom block which has a kinda similar behavior https://misode.github.io/loot-table/?version=1.21&preset=blocks/brown_mushroom_block
You may need to change the block event or some tags of your block as well to make this work.
Here is an example lootJS script I made to recreate the loot tables of some ores which didn't work properly inside my modpack.
LootJS.lootTables(event => {
const rawOres = ['copper', 'iron', 'gold'];
function createOreTable(block, item, lootTable) {
if (lootTable == undefined) {
lootTable = block.replace(':', ':blocks/');
}
event.getLootTable(lootTable).firstPool(pool => {
pool.addEntry(
LootEntry.alternative(
// loot block when using silk touch
LootEntry.of(block).when(c =>
c.matchTool(
ItemFilter.tag("c:tools").and(ItemFilter.hasEnchantment("minecraft:silk_touch"))
)
),
// loot item otherwise
LootEntry.of(item).applyOreBonus("minecraft:fortune")
)
)
})
}
// Remove bugged loot tables
event.clearLootTables(/.*blocks\/(deepslate_)?diamond_ore.*/);
event.clearLootTables(/.*blocks\/(deepslate_)?(copper|iron|gold)_ore.*/);
// Create new loot tables
createOreTable('minecraft:diamond_ore', 'hardmodeores:diamond_shard');
createOreTable('minecraft:deepslate_diamond_ore', 'hardmodeores:diamond_shard');
rawOres.forEach(m => {
createOreTable('minecraft:' + m + '_ore', 'minecraft:raw_' + m);
createOreTable('minecraft:deepslate_' + m + '_ore', 'minecraft:raw_' + m);
});
})
Documentation for LootJS