#cancel craft on specific conditions

6 messages · Page 1 of 1 (latest)

deft night
#

so i have enchanted item and item, that after merging in crafting grid take enchantments from item and destroy item, creating book with enchantments on that book
i want to disable this mechanic with specific item, but i cant figure out how i can access the item list, that was used to craft this item

ItemEvents.crafted('minecraft:enchanted_book', event => {
    //if(event) get list of used for craft items? if any of them is "minecraft:iron_leggins"
    event.cancel()
})
dusty latchBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

deft night
#

tried something like this, didnt worked, no output to console

ItemEvents.crafted(event => {
    let containsIronLeggings = false;
    for (let i = 0; i < event.inventory.size; i++) {
        let item = event.inventory.getItem(i);
        console.log(item + " " + item.id);
        if (item && item.id.includes('minecraft:iron_leggings')) {
            containsIronLeggings = true;
            break;
        }
    }

    if (containsIronLeggings) {
        event.cancel();
    }
});
#

ohh, now i see in console that crafted event is not cancelable

now the question what event i need to use

deft night
#

i just forked enigmatic and added blacklist feature, nvm