CraftTweaker

CraftTweaker

151M Downloads

cannot cast KnownTag<ItemDefinition>[] to IIngredient[]

TheKidThatCodes opened this issue ยท 3 comments

commented

Issue description

using MCTags as recipe ingredients does not work

Steps to reproduce

script

Script used

https://gist.github.com/TheKidThatCodes/73738b3ab7ef51285f3b59a9166b51b5

The crafttweaker.log file

https://gist.github.com/TheKidThatCodes/2ee3ec2e56fbf6e226b4b935ec58e94a

Minecraft version

1.20.4

Modloader

Fabric

Modloader version

0.15.9

CraftTweaker version

17.0.13

Other relevant information

No response

The latest.log file

irrelevant

commented

I"m not sure how you are getting that error, the script you have given is cut off according to the log file.

This script does work though and I believe will do what you want

import crafttweaker.api.item.IItemStack;

<tag:items:crafttweaker:blockchanting_pickages_blocks>.add(<item:minecraft:coal_block>);
<tag:items:crafttweaker:blockchanting_pickages_blocks>.add(<item:minecraft:lapis_block>);
craftingTable.addShapeless(
    "blockchanting_pickages",
    <item:minecraft:iron_pickaxe>,
    [<tag:items:minecraft:pickaxes>, <tag:items:crafttweaker:blockchanting_pickages_blocks>],
    (usualOut as IItemStack, inputs as IItemStack[]) => {
        if <item:minecraft:coal_block>.matches(inputs[1]) {
            return inputs[0].withEnchantment(<enchantment:autosmeltenchant:auto_smelt>, 1);
        }
        if <item:minecraft:lapis_block>.matches(inputs[1]) {
            return inputs[0].withEnchantment(<enchantment:minecraft:fortune>, 1);
        }
            return usualOut;
    });
commented

i just used .asIIngredient() to fix my problems because the array of inputs was the thing erroring

commented

oops im sorry i fixed this a while back and forgot to close the issue