Modding:Content Tutorial Simple Recipe

From Vintage Story Wiki
Revision as of 13:29, 24 March 2024 by Nateonus (talk | contribs) (First recipe.)
Other languages:
  • English

This page was last verified for Vintage Story version 1.19.4.


Introduction

Objective

In this tutorial, you will create two new grid recipes for our previously made item and block! Recipes are a great way of allowing players to access your new content.

Assets

Before starting, it is recommended you download the workspace and assets for this tutorial. The completed files can also be found here.

This tutorial starts with the following assets:

  • Mod Setup & Folder Structure
  • Premade Blocktype file
  • Premade Itemtype file
  • Premade Lang file
  • Texture & Shape Files
  • Empty Grid Recipe Files

Prerequisites

This tutorial will assume you understand the following topics:

Although not necessary, it is recommended to have completed the following tutorials:

  • 2. Simple Item
    • The 'Simple Wand' item is included in the tutorial setup.
  • 3. Simple Block
    • The 'Simple Gold Block' is included in the tutorial setup.

Navigating Assets

Browse the downloaded workspace. You should have an understanding of most of the files that currently exist, however there are two new files:

  • assets/simplerecipe/recipes/grid/simplewandrecipe.json - An empty json file. This will be used to create a recipe for the 'Simple Wand' item.
  • assets/simplerecipe/recipes/grid/simpleblockrecipe.json - An empty json file. This will be used to create a recipe for the 'Simple Gold Block'.

Recipe File Structure

As you may have noticed, recipes are all stored within the 'recipes' folder - However there is a list of subfolders that determine the type of recipe.

This tutorial uses the 'grid' folder, which tells the game that any files stored within that folder are recipes to be made in the grid.

The valid recipe types (and therefore folders) are:

  • alloy - Allows creation of different alloyed metals in a crucible.
  • barrel - Allows creation of objects within a barrel.
  • clayforming - Allows creation of objects in the clayforming system.
  • cooking - Allows creation of food within a cooking pot.
  • grid - Allows creation of objects by using the crafting grid.
  • knapping - Allows creation of stone objects using the knapping system.
  • smithing - Allows creation of metal objects on an anvil.

Creating the Item Recipe

Unlike when creating items and blocks, recipes can be somewhat difficult to test before they are complete, as all the information is required before the recipe will be created.

When creating recipes, it is a good idea to visualize what you are creating. This is the recipe you will be creating for this section:

SimpleRecipeTutorialSimpleWandRecipe.png

One clear quartz, on top of two sticks. It is, after all, a magic wand.

Recipe File

Open the 'simplewandrecipe.json' file inside 'recipes/grid'.

To create a new grid recipe, the game needs the following information:

  1. Ingredients - This defines what objects are used in the grid to create the output.
  2. Pattern - This defines how the ingredients are arranged in the grid, as well as the width and height of the recipe.
  3. Output - This defines what object will be given to the player when the recipe is complete.

You will notice that this information can be listed in any order in the json file.

Recipe Pattern

To begin, you need to define the recipe pattern inside your json file.

{
	"ingredientPattern": "Q,S,S",
	"width": 1,
	"height": 3,

These three properties will define the pattern and shape of our recipe.

The 'ingredientPattern' property defines a list of letters. Each unique letter defines a new ingredient. Note that although this uses Q for quartz and S for stick, you can pick whatever letter you want. Do not worry about the format of this property right now, as it will be discussed in the next recipe.

The 'width' property defines how many columns the recipe uses.

The 'height' property defines how many rows the recipe uses.

Recipe Ingredients

For your recipe to function correctly, each unique letter in the previous 'ingredientPattern' property needs to be registed as an 'ingredient'.

Add the following code to your file, below the height property.

"ingredients": {
		"Q": {
			"type": "item",
			"code": "game:clearquartz"
		},
		"S": {
			"type": "item",
			"code": "game:stick"
		}
	},

The 'ingredients' property is a little different to any properties used before in the tutorials, because it is a dictionary data type. In this case, it is simply a way of mapping each character in the pattern to an in-game object. There are two unique characters in the pattern, Q and S, so we need to add both of these to the list. When adding an ingredient, you need to include its type and code. The type is simple - either "item" or "block" depending on which one it is. The code is the item's unique identifier. A future tutorial will discuss multiple ways of finding an objects code, but for now we can use game:clearquartz and game:stick.

When all the unique characters have entires, you can move on.

Recipe Output

The recipe output determines what object this recipe will make. Add the final section of code to your file, below the 'ingredients' section.

"output": {
		"type": "item",
		"code": "simplewand"
	}
}

You may notice that the 'output' property is defined very similarly to an ingredient, using identical 'type' and 'code' properties inside of it. In this instance, to create the simplewand item, we fill in using the item type and simplewand code.

Finalized Recipe

Your first recipe should now be complete! You should be able to test it by going on the "simplewand" page in the in-game handbook, or trying to create your item in survival mode.

Here is the full recipe for comparison:

Final Recipe...
{
	"ingredientPattern": "Q,S,S",
	"width": 1,
	"height": 3,
	"ingredients": {
		"Q": {
			"type": "item",
			"code": "game:clearquartz"
		},
		"S": {
			"type": "item",
			"code": "game:stick"
		}
	},
	"output": {
		"type": "item",
		"code": "simplewand"
	}
}

Conclusion

SimpleRecipeTutorialSimpleGoldBlock.png

Congratulations, you have now created your first block! This tutorial should have given you greater understanding of blocks, textures, sounds and language files, as well as the basics of modding for Vintage Story!

Next Steps...

If you want to test your knowledge, consider doing the tasks under the Going Further section below.

When you're ready, try out the next tutorial: Simple Recipes. This will show you how to create recipes for the assets you have created.

Going Further

Want to make some additional changes to this mod? Try and achieve the following things!

Change the color of the block

To achieve this...
Modify the shinygoldtexture.png texture to a different color.

Change the block to only be mined with at least a tier 1 tool. Note that you will have to add a new "requiredToolTier" property

To achieve this...
Add "requiredToolTier":1 to the blocktype file.

Change your modid and domain to something else

To achieve this...
Modify both the modid entry in modinfo.json, and change the name of the 'simpleblock' folder in 'assets'.

Rename your 'Simple Gold Block'

To achieve this...
Change the entry for simplegoldblock in your en.json lang file.

Create another block with a different texture and properties

To achieve this...
Create a new block texture with a different name, and a duplicate blocktype file. In the new blocktype file, change the block code and change the texture property to your new texture path. Modify the properties to change the type of block. Don't forget to add new lang translation entries!


Content Modding
Basics Content Mods Developing a Content Mod
Tutorials
Concepts Modding Concepts Variants Domains Patching Remapping World Properties
Uncategorized
Icon Sign.png

Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.

Modding
Modding Introduction Getting Started Theme Pack
Content Modding Content Mods Developing a Content Mod Basic Tutorials Intermediate Tutorials Advanced Tutorials Content Mod Concepts
Code Modding Code Mods Setting up your Development Environment
Property Overview ItemEntityBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository