Modding:Basic Block/en: Difference between revisions

From Vintage Story Wiki
Updating to match new version of source page
(Updating to match new version of source page)
(Updating to match new version of source page)
Tags: Mobile edit Mobile web edit
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{GameVersion|1.19}}
__FORCETOC__
__FORCETOC__
{{PageOutdated|lookat={{ll|Modding:Content_Tutorial_Simple_Block|the simple block tutorial|nsp=0}}}}


Please read the tutorial [[Getting Started with Advanced Modding#Domains|Getting Started]] first, if you haven't done it already. This tutorial should introduce you into the basic of adding a block to the game using JSON files. If you want to add a block with functionality you should check out the tutorial for [[Advanced Blocks]]. There is a full list of all properties which can be defined inside the json file [[Block Json Properties|here]].
Please read about the {{ll|Modding:Asset System|nsp=1}} first, if you haven't done it already. This tutorial should introduce you into the basic of adding a block to the game using JSON files. If you want to add a block with functionality you should check out the tutorial for [[Advanced Blocks]]. There is a full list of all properties which can be defined inside the json file [[Block Json Properties|here]].


= A Simple Block =
= A Simple Block =
Line 14: Line 16:
== The Texture ==
== The Texture ==


We will use this texture for our block: [[File:Gold block.png]].
We will use this texture for our block: [[File:Gold block.png]]. <br>
(To create your own textures, you can use programs like [https://www.dotpdn.com/downloads/pdn.html/ PaintDotNet(free)], [https://www.piskelapp.com/ Piskel(free)], or [https://github.com/aseprite/aseprite/ Aseprite(free open source, or pay for precompiled)])


Now we need to put the texture at the right place so we can use it later on. Therefore you have to rename the texture to <code>mygoldtexture.png</code> and put it inside <code>assets/mygoldblock/textures/block/</code> in your workspace (you have to create those folders first). <code>mygoldblock</code> will be our domain.
Now we need to put the texture at the right place so we can use it later on. Therefore you have to rename the texture to <code>mygoldtexture.png</code> and put it inside <code>assets/mygoldblock/textures/block/</code> in your workspace (you have to create those folders first). <code>mygoldblock</code> will be our domain.
Line 22: Line 25:
The next thing we are going to need is a json file which will determine the properties of the block. For now we will keep it simple and will work with simple properties only. If you want to do some more advanced stuff you can take a look at the [[Block Json Properties|Block Properties Overview]].
The next thing we are going to need is a json file which will determine the properties of the block. For now we will keep it simple and will work with simple properties only. If you want to do some more advanced stuff you can take a look at the [[Block Json Properties|Block Properties Overview]].


Now you need to create a new json file in your editor (we recommend to use an editor with syntax highlighting, such as [https://notepad-plus-plus.org/ Notepad++] or Visual Studio).
Now you need to create a new json file in your editor (we recommend to use an editor with syntax highlighting, such as [https://notepad-plus-plus.org/ Notepad++] or [https://www.sublimetext.com/ Sublime Text]. If you are going to have many json files or some C#, then [https://code.visualstudio.com/ Visual Studio Code] is also a good pick).


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
code: "mygoldblock",
"code": "mygoldblock",
creativeinventory: { "general": ["*"] },
"creativeinventory": { "general": ["*"] },
blockmaterial: "Stone",
"blockmaterial": "Stone",
drawtype: "Cube",
"drawtype": "Cube",
textures: {
"textures": {
all: { base: "block/mygoldtexture" }
"all": { "base": "block/mygoldtexture" }
},
},
resistance: 3.5,
"resistance": 3.5,
sounds: {
"sounds": {
"place": "game:block/anvil",
"place": "game:block/anvil",
"walk": "game:walk/stone"
"walk": "game:walk/stone"
Line 69: Line 72:
Furthermore you need to add a <code>modinfo.json</code> file, check out [[Game_Content_Mod|this tutorial]].
Furthermore you need to add a <code>modinfo.json</code> file, check out [[Game_Content_Mod|this tutorial]].


To install the mod, navigate to the [[Vintagestory folder]] and place it inside the mods folder.
To install the mod, navigate to the [[VintagestoryData folder]] and place it inside the mods folder.


[https://wiki.vintagestory.at/images/4/4c/MyGoldBlockMod.zip MyGoldBlockMod.zip]
[https://wiki.vintagestory.at/images/4/4c/MyGoldBlockMod.zip MyGoldBlockMod.zip]
Line 88: Line 91:
Now we need to add those new textures to the json file.
Now we need to add those new textures to the json file.
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
textures: {
"textures": {
all: {  
"all": {  
base: "block/mygoldtexture",
"base": "block/mygoldtexture",
alternates: [{base: "block/mygoldtexture1" }, {base: "block/mygoldtexture2" }, {base: "block/mygoldtexture3" }],
"alternates": [{"base": "block/mygoldtexture1" }, {"base": "block/mygoldtexture2" }, {"base": "block/mygoldtexture3" }],
},
},
},
},
Line 112: Line 115:
So first of all we need some new textures again: [[File:Myirontexture.png]] [[File:Myirontexture1.png]] [[File:Myirontexture2.png]] [[File:Myirontexture3.png]]
So first of all we need some new textures again: [[File:Myirontexture.png]] [[File:Myirontexture1.png]] [[File:Myirontexture2.png]] [[File:Myirontexture3.png]]


Now we need to change a few things in our json file. We can add all kinds of different groups, but for now we keep it simple. We are adding group called <code>type</code>, with the states <code>gold</code> and <code>iron</code>. You can use any group code you want.
Now we need to change a few things in our json file. We can add all kinds of different groups, but for now we keep it simple. We are adding a [[Modding:Registry_Object_JSON_Parsing|variant group]] called <code>type</code>, with the states <code>gold</code> and <code>iron</code>. You can use any group code you want.
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
variantgroups: [
"variantgroups": [
{ code: "type", states: ["gold", "iron"] }
{ "code": "type", "states": ["gold", "iron"] }
],
],
</syntaxhighlight>
</syntaxhighlight>
Line 123: Line 126:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
texturesbytype: {
"texturesbytype": {
"*-gold": {
"*-gold": {
all: {  
"all": {  
base: "block/mygoldtexture",
"base": "block/mygoldtexture",
alternates: [{base: "block/mygoldtexture1" }, {base: "block/mygoldtexture2" }, {base: "block/mygoldtexture3" }],
"alternates": [{"base": "block/mygoldtexture1" }, {"base": "block/mygoldtexture2" }, {"base": "block/mygoldtexture3" }],
},
},
},
},
"*-iron": {
"*-iron": {
all: {  
"all": {  
base: "block/myirontexture",
"base": "block/myirontexture",
alternates: [{base: "block/myirontexture1" }, {base: "block/myirontexture2" }, {base: "block/myirontexture3" }],
"alternates": [{"base": "block/myirontexture1" }, {"base": "block/myirontexture2" }, {"base": "block/myirontexture3" }],
},
},
}
}
Line 144: Line 147:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
textures: {
"textures": {
all: {  
"all": {  
base: "block/my{type}texture",
"base": "block/my{type}texture",
alternates: [{base: "block/my{type}texture1" }, {base: "block/my{type}texture2" }, {base: "block/my{type}texture3" }],
"alternates": [{"base": "block/my{type}texture1" }, {"base": "block/my{type}texture2" }, {"base": "block/my{type}texture3" }],
},
},
},
},
Line 155: Line 158:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
code: "myshinyblock",
"code": "myshinyblock",
creativeinventory: { "general": ["*"] },
"creativeinventory": { "general": ["*"] },
variantgroups: [
"variantgroups": [
{ code: "type", states: ["gold", "iron"] }
{ "code": "type", "states": ["gold", "iron"] }
],
],
blockmaterial: "Stone",
"blockmaterial": "Stone",
drawtype: "cube",
"drawtype": "cube",
textures: {
"textures": {
all: {  
"all": {  
base: "block/my{type}texture",
"base": "block/my{type}texture",
alternates: [{base: "block/my{type}texture1" }, {base: "block/my{type}texture2" }, {base: "block/my{type}texture3" }],
"alternates": [{"base": "block/my{type}texture1" }, {"base": "block/my{type}texture2" }, {"base": "block/my{type}texture3" }],
},
},
},
},
resistance: 3.5,
"resistance": 3.5,
sounds: {
"sounds": {
"place": "game:block/anvil",
"place": "game:block/anvil",
"walk": "game:walk/stone"
"walk": "game:walk/stone"
Line 183: Line 186:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
variantgroups: [
"variantgroups": [
{ code: "type", states: ["gold", "iron"] },
{ "code": "type", "states": ["gold", "iron"] },
{ code: "condition", states: ["good", "used"]}
{ "code": "condition", "states": ["good", "used"]}
],
],
</syntaxhighlight>
</syntaxhighlight>
Line 192: Line 195:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
texturesbytype: {
"texturesbytype": {
"*-good": {
"*-good": {
all: {  
"all": {  
base: "block/my{type}texture",
"base": "block/my{type}texture",
},
},
},
},
"*-used": {
"*-used": {
all: {  
"all": {  
base: "block/my{type}texture",
"base": "block/my{type}texture",
alternates: [{base: "block/my{type}texture1" }, {base: "block/my{type}texture2" }, {base: "block/my{type}texture3" }],
"alternates": [{"base": "block/my{type}texture1" }, {"base": "block/my{type}texture2" }, {"base": "block/my{type}texture3" }],
},
},
},
},
Line 220: Line 223:
Therefore we will change the drawtype from <code>cube</code> to <code>json</code>:
Therefore we will change the drawtype from <code>cube</code> to <code>json</code>:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
drawtype: "json",
"drawtype": "json",
</syntaxhighlight>
</syntaxhighlight>


and the shape to <code>myshinymodel</code>
and the shape to <code>myshinymodel</code>
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
shape: { base: "block/myshinymodel" },
"shape": { base: "block/myshinymodel" },
</syntaxhighlight>
</syntaxhighlight>


Although this would be enough theoretically, we also should determine this block as being non-solid, to prevent graphical glitches.
Although this would be enough theoretically, we also should determine this block as being non-solid, to prevent graphical glitches.
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
sidesolid: {
"sidesolid": {
all: "false"
"all": "false"
},
},
sideopaque: {
"sideopaque": {
all: "false"
"all": "false"
},
},
</syntaxhighlight>
</syntaxhighlight>
Line 248: Line 251:
In order to specify the shape by type we need to remove the property <code>shape</code> and replace it with <code>shapebytype</code>:
In order to specify the shape by type we need to remove the property <code>shape</code> and replace it with <code>shapebytype</code>:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
shapebytype: {
"shapebytype": {
"*-good": {
"*-good": {
base: "block/myshinymodel1",
"base": "block/myshinymodel1",
},
},
"*-used": {
"*-used": {
base: "block/myshinymodel",
"base": "block/myshinymodel",
},
},
},
},
Line 267: Line 270:
= Moving Forward =
= Moving Forward =


The example shown here, while seemingly complex, only scratches the surface of what blocktypes are capable of in Vintage Story. It's highly suggested that you experiment with or at least familiarize yourself with all the known block properties before moving onto code mods. The best way to do this is to peruse the '''[[Modding:Block Json Properties | Block Properties]]''' page, which contains an ongoing list of all the usable JSON block properties currently incorporated into the game. Most properties in the list also have referenced files you can search for in the Vintage Story Assets folder. If you don't know where this is, you can find tutorials for each operating system at the [[Modding:The Asset System | Asset System]] page.  
The example shown here, while seemingly complex, only scratches the surface of what blocktypes are capable of in Vintage Story. It's highly suggested that you experiment with or at least familiarize yourself with all the known block properties before moving onto code mods. The best way to do this is to peruse the '''[[Modding:Block Json Properties | Block Properties]]''' page, which contains an ongoing list of all the usable JSON block properties currently incorporated into the game. Most properties in the list also have referenced files you can search for in the Vintage Story Assets folder. If you don't know where this is, you can find tutorials for each operating system at the {{ll|Modding:Asset System|nsp=0}} page.  


If you haven't yet, it's suggested you also check out the '''[[Modding:Basic Item | Basic Item]]''' and '''[[Modding:Basic Entity | Basic Entity]]''' pages to learn how simple JSON items and entities are added to the game.  
If you haven't yet, it's suggested you also check out the '''[[Modding:Basic Item | Basic Item]]''' and '''[[Modding:Basic Entity | Basic Entity]]''' pages to learn how simple JSON items and entities are added to the game.  
Line 273: Line 276:
However, if you're feeling like making the jump to code mods then you'll want to start by setting up your '''[[Modding: Setting up your Development Environment | Development Environment]]'''.
However, if you're feeling like making the jump to code mods then you'll want to start by setting up your '''[[Modding: Setting up your Development Environment | Development Environment]]'''.


{{Navbox/modding|Vintage Story}}
= Tutorial Video: How make mod without programming (in Russian) =
Thanks to ZigTheHedge for great detailed video
<br><youtube>BAr7etxj-1o</youtube> <youtube>fnFFh_enXiA</youtube>
 
{{Navbox/contentmodding}}
43,178

edits