Skip to content

How to create a type (Item \ Block) through JSON

Khanx edited this page Feb 1, 2021 · 3 revisions

The easiest way to create a type (item / block) is by means of JSON files. Developers decided to use the word "type" when referring to blocks and items, so in this guide, we will use the same word.

The difference between items and blocks is that blocks are placeable and have textures. Therefore, the creation of items and blocks is almost the same.

Before creating a type you need a modInfo.json file that indicates the information of your mod and the location of the JSON file in which you are creating the types. Without the modInfo.json file the mod will not work.

In the modInfo.json file it is necessary to indicate in the "jsonFiles" key the location of this JSON file, which will be of type addNewTypes.

Example of modInfo.json file from the Sign mod:

[
	{
		"name": "Sign",
		"version": "0.1.1.3",
		"enableddefault": true,
		"description" : "The player will able to place signs with text.",
		"dllpath": "Sign.dll",
		"compatibleversions":
			[
				"0.8.0"
			],
		"jsonFiles" : [
			{
				"relativePath" : "./autoload/types.json",
				"fileType" : "addNewTypes",
				"index" : -1000000
			}
		]
	}
]

This modInfo.json file indicates that the JSON file used to create the types is located in "./autoload/types.json"

The keys used by JSON file that adds type are here

An extract JSON file used by the Sign mod to add the Sign type (block) is shown below:

{
  "Khanx.Sign" : {
    "categories" : [
      "decorative",
	  "khanx"
    ],
    "customData" : {
      "colors" : ["#ff0000->#c89234", "#00ff00->#6b552d", "#0000ff->#ffffff"]
    },
    "isSolid": false,
    "icon" : "./../icons/sign.png",
    "needsBase": "true",
    "sideall": "planks",
	"onPlaceAudio" : "woodPlace",
	"onRemoveAudio" : "woodDeleteHeavy"
  }
}

More examples of JSON files that adds types:

As discussed earlier, the blocks have textures. In the event that you want to use textures that do not exist in the game, it is necessary to add them through another JSON file (work in progress).

In addition, it is possible to rotate some blocks to generate this rotation, it is suggested to use the JSON file of generateBlocks (work in progress).