Skip to content

Instantly share code, notes, and snippets.

@supersaiyansubtlety
Created November 7, 2019 01:56
Show Gist options
  • Save supersaiyansubtlety/414ee3bb4bec55f3ea3223a7c4a76066 to your computer and use it in GitHub Desktop.
Save supersaiyansubtlety/414ee3bb4bec55f3ea3223a7c4a76066 to your computer and use it in GitHub Desktop.
Attempts to find and replace all slab recipes using CraftTweaker's ZenScript
import crafttweaker.recipes.ICraftingRecipe;
import crafttweaker.item.IIngredient;
var slabRecipes = recipes.all;
for recipe in slabRecipes
{
if (recipe.output.name.toLowerCase has "slab")
{
var ingredients = recipe.ingredients1D as IIngredient[];
var i = 0;
while ((i < ingredients.length) & (ingredients[i] == null))
{
i+=1;
}
var input = ingredients[i];
var ouput = recipe.output;
output.amount = 4;
recipes.remove(recipe.output);
recipes.addShapedMirrored(input.displayName + "-to-" + output.displayName, output,
[
[null,null,null],
[null,null,null],
[null,input,input]
]
);
}
}
@PrincessRTFM
Copy link

I will point out that your recipe matrix is poorly designed. If you specify it like this, then it must be made in a 3x3 matrix, with the ingredients specifically in the bottom row, middle and right columns. Mirroring it only means that they can be in the left and middle columns too. Far better would be to not mirror it and specify the matrix as [[input, input]] instead, which only requires they be side-by-side.

@supersaiyansubtlety
Copy link
Author

Ah, thanks! Didn't know that was a possibility.

@PrincessRTFM
Copy link

I'm actually not sure if it's documented that there's a difference between the two, I've been using CT since MT and half of my knowledge is from having spaded things before the documentation was anywhere near this good. But in general, any row or column that consists only of null can be removed, and almost always should be too because the recipe handling isn't quite intelligent enough to understand that those slots can be completely disregarded, so it'll require that they be present and empty. Of course, sometimes that's what you want, but it'd be nice if it was mentioned on the docs somewhere...

@supersaiyansubtlety
Copy link
Author

Good to know, thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment