Modding:Basic Block: Difference between revisions

From Vintage Story Wiki
m
no edit summary
m (Double checked information and added version)
mNo edit summary
 
(15 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>
{{GameVersion|1.15}}
<!--T:1-->
<!--T:1-->
{{GameVersion|1.19}}
__FORCETOC__
__FORCETOC__
{{PageOutdated|lookat={{ll|Modding:Content_Tutorial_Simple_Block|the simple block tutorial|nsp=0}}}}


<!--T:2-->
<!--T:2-->
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 = <!--T:3-->
= A Simple Block = <!--T:3-->
Line 21: Line 22:


<!--T:8-->
<!--T:8-->
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)])


<!--T:9-->
<!--T:9-->
Line 32: Line 34:


<!--T:12-->
<!--T:12-->
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).


<!--T:13-->
<!--T:13-->
<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 88: Line 90:


<!--T:23-->
<!--T:23-->
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.


<!--T:24-->
<!--T:24-->
Line 113: Line 115:
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 144: Line 146:


<!--T:40-->
<!--T:40-->
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 157: Line 159:
<!--T:42-->
<!--T:42-->
<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 181: Line 183:
<!--T:45-->
<!--T:45-->
<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 193: Line 195:
<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 224: Line 226:
<!--T:50-->
<!--T:50-->
<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 235: Line 237:
<!--T:52-->
<!--T:52-->
<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 268: Line 270:
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>


Line 274: Line 276:
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>


Line 280: Line 282:
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 302: Line 304:
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 324: Line 326:


<!--T:70-->
<!--T:70-->
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.  


<!--T:71-->
<!--T:71-->
Line 337: Line 339:


<!--T:74-->
<!--T:74-->
{{Navbox/modding|Vintage Story}}
{{Navbox/contentmodding}}
</translate>
</translate>
Confirmedusers
566

edits