How to make a Minecraft Modpack Crafttweaker Adding Recipes Github repository for examplesIn this series. 模组MTRM可视化合成表编辑器 (MineTweaker RecipeMaker)的介绍页，我的世界MOD百科，提供Minecraft(我的世界)MOD(模组)物品资料介绍教程攻略和MOD下载。. CraftTweaker(MineTweaker 3)とは. CraftTweaker(MineTweaker 3)はMinecraft内に自作のレシピを簡単な記述のみで反映させることができる便利系Modです。 では、どのくらい簡単にレシピを追加できるのかというと、1レシピ当たり、数行(1～4行ぐらい？. 添加/删除 合成配方，模组MTMineTweaker 3的教程，我的世界MOD百科，提供Minecraft(我的世界)MOD(模组)物品资料介绍教程攻略和MOD下载。.
Before you can write any MineTweaker scripts, install MineTweaker first and create a '/scripts/' directory in the '/minecraft/' directory, if it is not already there. This should be at the same level as the '/mods/' and '/config/' directories. All scripts are written in files with the '.zs' file extension (for example, 'witchery.zs'). The name of these files does not matter to the scripts or MineTweaker, however it is recommended to not uses spaces or symbols (excluding underscores).
It is recommended you use the Atom Text Editor, along with the Atom-MineTweakerpackage rather then a normal text editor, but it is not required.
In ZenScript, a function is a procedure that does something, like add or remove a recipe. The most basic function in the print function, as shown below.
The print function will log a message into the minetweaker.log file in your minecraft directory. That file may contain other messages, but this should be found somewhere within it.
Notice the called function has a semicolon at the end of it. A semicolon is required after the end of each statement.
Most functions in MineTweaker relate to the addition and removal of recipes. It's important to know the unlocalized name of the item and blocks you want to use, as well as the mod ID that adds that particular item or block. Various tools exist to discover these, including NEI's data dumping feature.
To remove a recipe, a simple function is put into place.
When Minecraft is launched, you will find you can no longer craft Sticks. If this example, minecraft is treated as the mod ID, and stick is the unlocalized name of the Stick.
This will remove the crafting recipe for the Bed:
And this will remove the crafting recipe for the Blaze Rail from Natura.
Natura is the mod ID of Natura, and Blazerail is the unlocalized name of the Blaze Rail.
Remember: you can call multiple functions in one script, like shown below.
Spaces and new lines don't mean anything in ZenScript, meaning you can do some funky things.
Of course, for the sake of readability, it is recommend that each statement gets its own line.
Calling a function with multiple parameters and adding shaped recipes[editedit source]
In ZenScript, a parameter is the input you put into a function.
In the example above, the Stick is the parameter.
Anyway, often times a function needs more than one parameter. For example, adding a new recipe requires two; one for the output, and one for the recipe itself.
As you can likely guess, the above script adds the Diamond Pickaxe recipe.
Take some time to reevaluate the script:
- Notice the word null. In this case, null means nothing is required in that slot.
- Notice the square brackets ([ and ]). For each right square bracket, there's a left bracket. The entire recipe is in a set of square brackets, and each line is in another set of square brackets.
- Also notice the semicolon. Remember, each statement ends with a semicolon.
Here's another example:
Of course, that last example does not replace the Stone Pickaxe recipe; it just adds a new recipe for it. If you wanted to replace it, you'd have have to remove the recipe, and then add it again.
Variables and Values[editedit source]
In ZenScript, a Value is an item (or other type) that can be set and used later. That might sound complicated, but it's actually quite simple. The val keyword is used for declaring a value. For example,
declares a value named 'stonePick' with the value of '<minecraft:stone_pickaxe>'. Values are especially useful so you can type less and still get the same effect. For example,
can be simplified to:
It might not look like a big difference, but it really is if you use the value a lot. Do note using values are mostly optional, but they're considered a good coding practice for ZenScript and other similar programming languages.
A Variable is just like a value, but it can be set multiple times. For example,
will remove both the Glass block and the Lapis Block. If you replace 'var' with 'val', some sort of error will occur, and the script will likely not work.
The variable feature might not look very useful right now, but it's vital in more advanced scripts.
In ZenScript, a Comment is a structure in code that is ignored by the interpreter, but is created for readability.
That sounds kind of confusing, but it's really not complicated at all. A single-lined comment in ZenScript can be started with '#' or '//'
A multi-lined comment is started with '/*' and ended with '*/'.
Comments are used for a variety of reasons; for explaining confusing code, explaining what a function does, listing copyright information, and to disable code without deleting it.
More information[editedit source]
For more detailed information, please consult the MineTweaker 3 wiki.
- 1Basic Recipes
The most basic modifications you can perform in MineTweaker are recipe addition and removal.
As a little introduction, let's consider the recipe for sticks. In vanilla minecraft, it takes 2 wood planks to make 4 sticks, and they have to put above each other. But what if we want to change that? What if, say, we find it more logical to put the two wood block diagonally instead? (this stick is diagonal, right?)
Modifying the sticks recipe is wonderfully easy. Make a script with the following contents:
Open a new game (or reload scripts, if you are already in a game). Now take 2 oak wood planks and test your recipe.
It works? Great! But now you may have noticed a flaw in the recipe: if you put birch or spruce wood, it doesn't work!
Why doesn't it work? The 'tile.wood' item has subitems that are distinguished by not only the item name, but also by its meta value. By default, if you retrieve an item with the bracket syntax, MineTweaker assumes you want the item with meta value 0. And that's what it returned - the 'oak planks' item. But we want an ingredient which essentially means 'any kind of wood'.
Luckily, this is easy to fix. When using the bracket syntax, besides the name, we can also define a meta value. For instance,
<tile.wood:1> refers to spruce wood. We can also use the wildcard (*) to get an item meaning 'any meta value is good':
Thus, change your recipe and reload:
Fixed! Of course, you should use the ore dictionary entry for planks, which would be even better as it would be compatible with mod-added planks :)
Other kinds of recipes
Shaped recipes are recipes where the ingredients must be placed in the right shape in order for it to work. Not all Minecraft recipes are shaped - some don't care about the shape. MineTweaker supports those with the addShapeless function:
Now it doesn't matter how you place your planks - you can always craft sticks. Note that in this example, though, you can no longer craft the wooden pressure plate.
Since 3.0.7, it's also possible to register mirrored recipes. Continuing with our sticks (make sure to remove the previous recipes first):
Now it doesn't matter if you mirror the recipe - it still works!
Specific recipe removal
So far we decided that we would be removing all recipes for the stick. In vanilla minecraft, there is also only one, so that's not an issue. But what if we want to be more specific? Often there are multiple recipes for the same item, and we may want to remove one yet keep the others.
It is possible to be more specific in that case:
This will remove only a single recipe - even if there are other recipes.
It is also possible to remove all recipes that are shaped, or all recipes that are shapeless, by simply calling:
Also, wildcard patterns can be used to indicate that any kind of item would match for a certain position, as long as it's not empty:
Likewise, when removing shapeless recipes, it is possible to only specify one or more ingredients of the shapeless recipe and then tell minetweaker that the remainder of the recipe may contain anything:
Don't be fooled by the item name - it is the wool block.
Subitems and damage values
Quite often, items have multiple subitems. A very well-known example are coal and charcoal. Both have the same ID (item.coal) but have a different meta value.
When loading an item, you can specify the meta value for the subitem:
When the subitem is not specified, :0 is filled in for the subitem.
If you want a recipe to match any subitem, you can use the wildcard syntax:
Many kinds of items can also be damaged. When using such item as ingredient for a recipe, by default, no damage is allowed. For instance:
In the recipe above, a damaged pickaxe would not be accepted. This can be changed easily with the .anyDamage() modifier:
Reloading and recipes
When you reloaded the scripts, you may have noticed that if you reloaded a script, the recipe is not duplicated. Likewise, if a recipe addition is removed from the script and the script is reloaded, the recipe is effectively removed from the game even though there may be no statement explicitly requesting such removal.
Minetweaker Recipe Maker Tutorial
MineTweaker remembers actions such as recipe addition and removal. When a script is reloaded (or loaded by joining a different server), MineTweaker will first undo all the recorded changes that were made before it executes the new script.
Many mod machines, however, do not support such recipe removal. In that case, the recipe will be 'stuck' in the game until the entire game is reloaded. For a server, this means that the recipe will be stuck in the list until the server is restarted; for a client, it means that the recipe will be shown and acted upon as if it existed, though when a crafting attempt is made, actual crafting would fail. There is no fix to such behavior; it is up to the respective mod authors to provide a sufficient API to ensure that recipe removal is possible.
Do you find yourself looking up the same item over and over again using the bracket syntax? It may be handy to remember the value for later; which can be done with the val and var statements:
In this example, var can be used too:
The difference between var and val is that a val cannot be modified after it is declared:
Avaritia Mod Recipes
Using item IDs
Find yourself having issues with Item IDs? You can still use the old bracket syntax with item IDs, but only in the 1.6.4 version: