Mrthomas20121-Mods / tfctweaker

Add Crafttweaker compat to TFC.
3 stars 0 forks source link

[1.18.2] Adding welding recipe causes error "cannot cast IItemStack to ItemStackProvider" #6

Closed chemlzh closed 1 year ago

chemlzh commented 1 year ago

[Mod Version] Forge: 1.18.2-forge-40.2.4 CraftTweaker: CraftTweaker-forge-1.18.2-9.1.207.jar TerraFirmaCraft: TerraFirmaCraft-Forge-1.18.2-2.2.21.jar TFC tweaker: TFCTweaker+1.18.2-0.0.2.jar

[Bug Description] Copy addRecipe line from docs to add welding recipe, save as .zs file, and put it under the script folder

import mods.tfc.WeldingRecipe;

<recipetype:tfc:welding>.addRecipe("welding_test", <item:tfc:metal/ingot/copper>, <item:tfc:metal/double_ingot/copper>, 1, <item:tfc:metal/double_sheet/copper>);

Enter the game, type "/reload" and press enter key. Waiting for some time, and CraftTweaker will throw error message.

[18:08:11.108][ERROR]: tfc_metallum_create_compact.zs:11:0: tfc_metallum_create_compact.zs:11:0: No matching method found for addRecipe:

Parameter 4: cannot cast IItemStack to ItemStackProvider
Mrthomas20121 commented 1 year ago

that's not a bug. you need to give it an itemStack provider. not an itemstack

Mrthomas20121 commented 1 year ago

https://docs.blamejared.com/1.18/en/mods/TFCTweaker/Api/Ingredient/ItemStackProvider

Mrthomas20121 commented 1 year ago

but i see why you were confused, the docs is wrong

chemlzh commented 1 year ago

that's not a bug. you need to give it an itemStack provider. not an itemstack

Then how can I do to convert itemStack to itemStackProvider? Using ItemStackProvider.none(...) ?

Mrthomas20121 commented 1 year ago

yes

ItemStackProvider.none(<item:tfc:metal/double_sheet/copper>);
chemlzh commented 1 year ago

Today I tried the modified welding recipe, and the game threw this error.

welding_recipe_error

Is there any parameter that I have forgotten to fill in?

chemlzh commented 1 year ago

I have found the question: in the newer version of TFC: TNG (for my condition, it's 1.18.2-2.2.21), the welding recipe also has a forging bonus boolean variable called combineForgingBonus.

    public WeldingRecipe(ResourceLocation id, Ingredient firstInput, Ingredient secondInput, int tier, ItemStackProvider output, boolean combineForgingBonus)
    {
        this.id = id;
        this.firstInput = firstInput;
        this.secondInput = secondInput;
        this.tier = tier;
        this.output = output;
        this.combineForgingBonus = combineForgingBonus;
    }

And the WeldingRecipe in your TFCTweaker doesn't have this variable, therefore bug has occured.

    public void addRecipe(String name, IIngredient input1, IIngredient input2, int tier, TFCItemStackProvider output) {
        CraftTweakerAPI.apply(new ActionAddRecipe<>(this, new WeldingRecipe(Constants.identifier(name), input1.asVanillaIngredient(), input2.asVanillaIngredient(), tier, output.getInternal())));
    }
Mrthomas20121 commented 1 year ago

i see. will look into it.