CraftTweaker

CraftTweaker

186M Downloads

Can't get recipe output or items used to craft at all.

Famous5000 opened this issue ยท 2 comments

commented

Issue description

When attempting to check a recipe, which isn't null, none of the fields I can check appear to work, and there's no way for me to debug what it has inside of the code.

Example:
I've tried the following:
var outputStackSize = originalRecipe.output.amount;
var outputStackSize = originalRecipe.getResult();
var outputStackSize = originalRecipe.getResults().amount;
var outputStackSize = originalRecipe.getResultItem().amount;
var inputs = originalRecipe.getIngredients();
None of the above things work to get anything of what I needed.

Steps to reproduce

No response

Script used

https://pastebin.com/zSmcVtQk

The crafttweaker.log file

https://pastebin.com/02t5p8TU

Minecraft version

1.20.1

Modloader

Forge

Modloader version

42.2.19

CraftTweaker version

14.0.30

Other relevant information

Mod recipes I'm trying to modify are part of Mystical Agriculture but that shouldn't affect anything

The latest.log file

https://pastebin.com/K1iuv8iR

commented

Due to a bug in the scripting engine, you need to do:

craftingTable.getRecipeByName(source) as Recipe<Container>;

Your full script would be:

import crafttweaker.api.recipe.type.Recipe;
import crafttweaker.api.world.Container;
 
val conversions = [
    [
        "mysticalagriculture:essence/minecraft/iron_ingot",
        "minecraft:raw_iron",
        "essence/minecraft/raw_iron",
    ]
];
 
for index,value in conversions {
    var source = value[0];
    var replacement = value[1];
    var recipeName = value[2];
 
    var originalRecipe = craftingTable.getRecipeByName(source) as Recipe<Container>;
    if (originalRecipe == null) {
        println("Dumbass Original Recipe is NULL.");
    } else {
        println("Original Recipe is NOT Null.");
        var outputStackSize = originalRecipe.output.amount;
		var outputStackSize = originalRecipe.getResult();
        var inputs = originalRecipe.getIngredients();
 
        craftingTable.addShaped(recipeName,inputs,<item:${replacement}> * outputStackSize);
    }
}
commented

Resolved, thank you so much for the help! [Ended up having a different method being suggested]