Skip to main content

Your First Script

Create the Script

Inside of your scripts directory, create a new file called tutorial.zs or whatever you would like to call the script. Now open the newly created file with your favourite text editor.

Adding a New Recipe

For this example, we'll be adding a new recipe to the Workbench. The Workbench is a block primarily used for crafting all furniture in the mod. To do this, we are going to target the recipe type refurbished_furniture:workbench_constructing.

In your script, it should look something like this.

scripts/tutorial.zs
<recipetype:refurbished_furniture:workbench_constructing>

Now we need to call the addRecipe function. This function is how you add new recipes. Keep in mind that this function accepts different arguments depending on the recipe type. For workbench constructing recipes, we need an id, result, and materials.

  • id - A String that represents the name for this recipe
  • result - An IItemStack that represents the item that is constructed
  • materials - An array of IItemStack or IIngredient that represents the items needed to construct the result

Let's say we want to add a recipe to construct 10 Diamonds from 4 Apples and 2 Sticks, our arguments will be:

  • "ez_diamonds"
  • <item:minecraft:diamond> * 10
  • [<item:minecraft:apple> * 4, <item:minecraft:stick> * 2]

When we write the addRecipe call in the script, it will look like this.

scripts/tutorial.zs
<recipetype:refurbished_furniture:workbench_constructing>.addRecipe("ez_diamonds", <item:minecraft:diamond> * 10, [<item:minecraft:apple> * 4, <item:minecraft:stick> * 2]);

Finally save your script.

Testing the Recipe

If you successfully completed the above steps, start up your game if you haven't already and load into a world. If you are already loaded into a world, exit back to the main menu and load the world again to refresh recipes. If you open the Workbench, you should see the ez_diamonds recipe we above from above.

Final Words

You are now ready to explore further! Head over to the Recipe Types page to learn about all the new recipe types and their functions. If you need extra help, feel free to join our Discord community and post a ticket in #mod-support and MrCrayfish or the community will assist you with your problem.