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)
Line 15: Line 15:
== 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 23: Line 24:
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 70: Line 71:
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 89: Line 90:
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 115: Line 116:
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 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 124: Line 125:


<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 145: Line 146:


<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 156: Line 157:
<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 184: Line 185:


<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 193: Line 194:


<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 221: Line 222:
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 249: Line 250:
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",
},
},
},
},
43,324

edits