Beginner's Guide To 1.12.2 Crafttweaker
This information is specific to 1.12.2 Crafttweaker. There are important syntactical changes in the 1.13+ versions of the mod, and while some of the general principles detailed here are still applicable, the particulars can differ quite a bit.
Special thanks to Hubry for fixing my formatting and helping me make this presentable.
Crafttweaker is a mod that reads
.zs files from your modpack's
scripts folder (a folder it creates on launch, empty, if no such folder exists), to "do things."
.zs file is just a
.txt file that you've changed the file extension of. It just has plain text in it, that you type there. If you do not know how to change the file extension of a file, you need to configure windows to show you file extensions, then, you can change them by renaming the file: How to show file extensions on windows.
I'm not sure how best you learn "things" so I'm gonna do 2 things: I'm gonna link to the 3 sections of the crafttweaker documents that are most relevant to someone just starting out with it, and then I'm gonna post an example script and pick it apart a step at a time:
https://docs.blamejared.com/1.12/en/ : The docs. Dropdowns on the left for browsing.
https://docs.blamejared.com/1.12/en/Getting_Started/ : what scripts are, where they go, some basic particulars of how they work.
https://docs.blamejared.com/1.12/en/Vanilla/Recipes/Crafting/Recipes_Crafting_Table/ : A description of how adding and removing craftingtable recipes looks/works.
https://docs.blamejared.com/1.12/en/Vanilla/Recipes/Furnace/Recipes_Furnace/ : A description of how adding and removing furnace recipes looks and works.
But hold off for a second, you might want those open, but let's just get our hands dirty:
An Example Crafttweaker Script
//Removing The Minecraft Door Recipes recipes.remove(<minecraft:wooden_door>); recipes.removeByRecipeName("minecraft:iron_door"); //Adding New Horrible Minecraft Door Recipes recipes.addShapeless("new_wooden_door_recipe", <minecraft:wooden_door> * 6, [ <minecraft:piston>, <minecraft:lever>, <ore:plankWood>, <ore:plankWood>, <ore:plankWood>, <ore:plankWood> ]); recipes.addShaped("new_iron_door_recipe", <minecraft:iron_door>, * 9 [ [<ore:blockIron>, <ore:blockIron>], [<minecraft:iron_trapdoor>, <minecraft:repeater>], [<ore:ingotIron>, null] ]); //Removing Furnace Recipes For Things For No Good Reason furnace.remove(<minecraft:dye:2>); furnace.remove(<minecraft:iron_nugget>, <minecraft:chainmail_helmet>); furnace.remove(<minecraft:iron_nugget>, <minecraft:chainmail_chestplate>); furnace.remove(<minecraft:iron_nugget>, <minecraft:chainmail_leggings>); furnace.remove(<minecraft:iron_nugget>, <minecraft:chainmail_boots>); //Recipe For Green Dye Using Tall Grass furnace.addRecipe(<minecraft:dye:2>, <minecraft:tallgrass>, 0.05);
Oh God what have we done. Okay, let's start.
// is a comment line. Anything after a double-slash on a line is treated as a comment, and does not "do anything" in the script.
You could, if you cared to, type whatever you want in the comments. Comments describing what the script does, or is for, or how it works, is what people often do, but, you can follow your heart!
There's a few ways of Removing a recipe, the first of which involves calling the
recipes.remove method, and then defining the item for which you are removing the recipe inside the
() of that method call. Crafttweaker doesn't care too much about where spaces and carriage returns go, so, at the end of any line, any instruction, it's loooking for a
; to tell it that instruction is over. You're gonna see a lot of semicolons. But if we're gonna remove a recipe by what item it outputs, we need to understand how to refer to an item.
How to refer to items in crafttweaker
So, referring to an item! There's 2 primary ways, that both basically look the same:
To see the ID of an item, and/or the ore dictionary tags it has, holding it in your hand and using the command
/ct hand will reveal this info in the chat, and, copy the item id to your clipboard for easy pasting into a script.
Items by Mod Id and Item ID
<modname:item_name:metadata_value> : the name of the mod, and the item, and the metadata number, inside a pair of
<>'s as brackets. By way of concrete example:
<minecraft:wool:15> is minecraft's black wool, which has the metadata value of 15!
Items By Ore Dictionary Tag
<ore:theOreTagOfTheItem> : the word
ore, and then the name of the ore dictionary tag: Usually used to allow all instances of items with that tag to be used in a recipe, or in the case of removal, to remove all recipes for items that have that tag.
<ore:blockWool> is the tag shared by all the colors of sheepwool!
Remove A Recipe By Recipe ID
The other most-important way to zap a recipe is to remove it by recipe name. This is good for items that have 70 different recipes, but you're mainly concerned with removing a specific one. Recipe ID's can be seen by activating advanced tooltips (
F3+H with no UI open) and then mousing over the recipe's output in JEI.
So we've removed 2 recipes: Iron and wooden doors. Let's add back some new recipes for them!
Adding A Shapeless Recipe
Our first example is a shapeless recipe. The layout of this recipe type is: The method call, and then a bunch of things, in order, inside the
recipes.addShapeless("name", <modname:item_output> * 6, [<modname:item_input>, <modname:item_input>]);
"name" : A name, that's a string, no caps, no spaces, no
:'s, which is just text inside quotes:
The Recipe Output: Next is the item we're gonna add a recipe for, and, optionally, how many of that item we want the recipe to make. In this case, 6! For the output of a recipe, we need to be specifying a very specific Item, so no using ore tags here. It needs to know exactly which item to make, not be offered a smorgasboard.
The Array Of Ingredients: An array! An array is a list of similar things inside a pair of
 brackets, divided by
, commas! This is an array of
IIngredients, which are basically just items referred to in the ways above. Either
<ore:ingotIron>. This array is defining all the items the player needs for the recipe. Since it's a shapeless recipe, the game won't care what order they're arranged in the crafting grid. But they will need each of them: a lever, a piston, and 4
The End Of The Recipe: And then, at the end of the array, to close everything out, we put a
) to close out the initial open paren, and a
; to tell crafttweaker that that is a whole instruction.
Our second example is a shaped recipe:
recipes.addShaped("name", <modname:item_output> * 9,
It starts out very similar to the shapeless one, except that the name of the methodcall is different. There's a name, there's an output item, we can tell it
* 9 to make it craft 9 of them. All good.
But shaped recipes care about the shape the items make in the crafting grid. And to do this, it needs an array, but not just an array. An array of arrays!. 1 array for each row. And the row arrays are an array of up to 3
IIngredients (items). I've stuffed the example full of carriage returns for "readability", but the structure of the array of arrays is basically this:
[ [ items ], [items], [items] ]
You can use 1, 2, or 3 row arrays. And they can be 1, 2, or 3 items long (though all 3 need the same length). I specifically chose the door recipes to show what a 2x3 recipe would look like. Because the rows are only 2 items "wide", you can make this recipe either on the left or right half of the crafting table.
But at the end of this recipe, in the third row, on the right side, is a mystery:
This is used when you specifically want/need an open space in the crafting grid. For vanilla examples, the middle spot in the chest and furnace recipes are
After closing up our arrays, we close up the open paren with a
), and end the instruction with a
Bam, after nuking our door recipes, we now have 2 much "better" recipes that are very good and no one would groan exasperatedly at them.
Time to ruin furnace recipes instead.
Removing Furnace Recipes
Removing furnace recipes looks very similar to removing crafting recipes. You call the method, and, the first item you define is the output for which you wish to remove the furnace recipes of. If you only define the output, it will remove any and all furnace recipes that result in that output. In our first case, we're removing all recipes that result in
<minecraft:dye:2>, minecraft dye, with metadata value 2: the green one.
The next 4 removals are defining a specific input from which we wish to remove that output. Particularly, we don't want any of the chainmail armors to smelt into iron nuggets, but, we don't want to remove the ability to smelt other things into iron nuggets, so, we define the specific inputs for which we wish to remove the recipe for iron nuggets from.
We have destroyed, but now we must create a new furnace recipe
At the basic level, they have 3 parameters:
furnace.addRecipe(<modname:item_output>, <modname:item_input>, xpAmount)
The output has to be a specific item, like
<minecraft:wool:0>, the input can be an IIngredient though, allowing either
The xp amount is just a floating point value of XP points per execution of the recipe, which will be awarded to the player when they visit the furnace and pull out the items.
And there we have it. We've ruined doors. We've made dye horrible. Chainmail got somehow worse. All in a day's work for a modpack maker. :3