Modding:Basic Block: Difference between revisions

From Vintage Story Wiki
Line 70: Line 70:
[http://wiki.vintagestory.at/images/4/4c/MyGoldBlockMod.zip MyGoldBlockMod.zip]
[http://wiki.vintagestory.at/images/4/4c/MyGoldBlockMod.zip MyGoldBlockMod.zip]


A proper mod manager will be added to the game once there is a few serious mods out there (go bug tyron about it ;-).
A proper mod manager will be added to the game once there is a few serious mods out there (go bug tyron about it ;-) ).


= Advanced Properties =
= Advanced Properties =

Revision as of 12:54, 10 January 2017


This tutorial should introduce you into the basic of adding a block to the game using JSON files. Down below you can find a complete list of all existing properties. If your block requires more than just a JSON file there is a tutorial for Advanced Blocks. There is a full list of all properties which can be defined inside the json file Block Json Properties.

A Simple Block

To get started let's start with something simple. In our example we will add an ordinary gold block (will be for decorative use only) to the game.

The Texture

First of all we need a texture. We will add a gold block to the game using this texture: Gold block.png.

Now we need to copy the texture to the game assets. Therefore navigate to the Vintagestory folder and place it in assets\textures\blocks\metal\. Eventually rename it to mygoldtexture.png

The JSON file

Now we need a json file which will determine the properties this block has. For now we keep it simple and only cover simple properties, but there are a lot of other things you can do with. Here is a full list of all Block Json Properties. So create a new json file in your editor (we recommend to use an editor with syntax highlighting, such as Notepad++ or Visual Studio) named mygoldblock.json.

{
	code: "mygoldblock",
	creativeinventory: { "default": ["*"] },
	shape: { base: "basic/cube" },
	blockmaterial: "Stone",
	drawtype: "cube",
	textures: {
		all: { base: "metal/mygoldtexture" }
	},
	resistance: 3.5,
	sounds: {
		"place": "block/anvil",
		"walk": "walk/stone"
	}
}


Short explanation of each line:

  • code: A unique identifier for your block. If you plan a larger mod, it is suggested to prefix your modname to the identifier.
  • creativeinventory: The creative inventory tabs the block should be shown in (currently only 1 tab available)
  • shape: Which model the block should use
  • drawtype: Determines the drawing system, use 'cube' for normal full cubes or 'json' for custom created shapes.
  • textures: What textures to apply. For simple blocks you can define one single texture for 'all' faces or define one for every facing ('north', 'east', 'west', 'south', 'up', 'down')
  • resistance: How many seonds of real time it takes to break the block without tools
  • sounds: The sounds to be played when placing/breaking or walking on the block

Now navigate to the Vintagestory folder again and place the json file inside it in assets\assets\blocktypes\metal\.

Testing

Finally we got everything ready to run our first test. Therefore start Vintagestory as usual, you should be able to find your block inside the creative inventory.

2017-01-10 12-33-45.png.

Naming the Block

To give the block a proper name, you currently have to manually add a line like this in the file assets/lang/en.json

	"block-mygoldblock": "Block of Gold",

A better way of handling naming and translation will be added once its desired.

Distributing a mod

The current modding system does not yet support mod-specific asset folders. The current way of doing it is to create a zip file a user can extract into his game folder that will extract the files into the right folders. Example:

MyGoldBlockMod.zip

A proper mod manager will be added to the game once there is a few serious mods out there (go bug tyron about it ;-) ).

Advanced Properties

Now we do some more advanced stuff with our lovely gold block. Will add different variants and custom shapes. So let's get started.

Random Textures

Variants

Custom Shapes

Variants of Custom Shapes