Modding:Content Tutorial Simple Block: Difference between revisions

From Vintage Story Wiki
Marked this version for translation
m (Minor formatting.)
(Marked this version for translation)
 
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>
<!--T:1-->
{{GameVersion|1.19.4}}
{{GameVersion|1.19.4}}
__FORCETOC__
__FORCETOC__


== Introduction ==
== Introduction == <!--T:2-->


=== Objective ===
=== Objective === <!--T:3-->
In this tutorial, you will create a new gold brick block! The block will be very simple, however completing this tutorial will show you how to create any number of new blocks. You will also get more practice on using textures and lang files, as well as an understanding of sound assets.
In this tutorial, you will create a new gold brick block! The block will be very simple, however completing this tutorial will show you how to create any number of new blocks. You will also get more practice on using textures and lang files, as well as an understanding of sound assets.


=== Assets ===
=== Assets === <!--T:4-->
Before starting, it is recommended you [https://github.com/Nateonus/vsmodexamples/releases/tag/SimpleBlockTutorial download the workspace and assets] for this tutorial. The completed files can also be found here.  
Before starting, it is recommended you [https://github.com/Nateonus/vsmodexamples/releases/tag/SimpleBlockTutorial download the workspace and assets] for this tutorial. The completed files can also be found here.  


<!--T:5-->
This tutorial starts with the following assets:
This tutorial starts with the following assets:


<!--T:6-->
* Mod Setup & Folder Structure
* Mod Setup & Folder Structure
* Empty block file
* Empty block file
Line 19: Line 22:
* Block texture file
* Block texture file


=== Prerequisites ===
=== Prerequisites === <!--T:7-->
This tutorial will assume you understand the following topics:
This tutorial will assume you understand the following topics:


<!--T:8-->
* [[Modding:Developing a Content Mod|Setting up a content mod and using an IDE.]]
* [[Modding:Developing a Content Mod|Setting up a content mod and using an IDE.]]
* [[Modding:Content Tutorial Basics|The functions of shape, texture and lang files.]]
* [[Modding:Content Tutorial Basics|The functions of shape, texture and lang files.]]
Although not necessary, it is recommended to have completed the following tutorial:
Although not necessary, it is recommended to have completed the following tutorial:


<!--T:9-->
* [[Modding:Content Tutorial Simple Item|2. Simple Item]]
* [[Modding:Content Tutorial Simple Item|2. Simple Item]]
** You will notice that creating an item and creating a block use very similar methods.
** You will notice that creating an item and creating a block use very similar methods.


== Navigating Assets ==
== Navigating Assets == <!--T:10-->
Using the downloaded workspace, have a look at the files that currently exist.
Using the downloaded workspace, have a look at the files that currently exist.


<!--T:11-->
* ''modinfo.json'' - The mod info file, which registers your mod with the ID 'simpleblock'.
* ''modinfo.json'' - The mod info file, which registers your mod with the ID 'simpleblock'.
* ''modicon.png'' - The mod icon file, which will be displayed on the mod manager menu.
* ''modicon.png'' - The mod icon file, which will be displayed on the mod manager menu.
Line 38: Line 44:
* ''assets/simpleitem/textures/block/shinygoldtexture.png'' - A texture file for the block.
* ''assets/simpleitem/textures/block/shinygoldtexture.png'' - A texture file for the block.


== Creating the Block ==
== Creating the Block == <!--T:12-->
In order to create a block, a file must be created inside the ''blocktypes'' folder. If using the provided workspace, there already exists a block file called simpleshinyblock. Open this file in your IDE.
In order to create a block, a file must be created inside the ''blocktypes'' folder. If using the provided workspace, there already exists a block file called simpleshinyblock. Open this file in your IDE.


<!--T:13-->
The most important property when creating an asset is the code, also known as an ID. To begin, copy and paste this into the opened simpleshinyblock file.<syntaxhighlight lang="json">
The most important property when creating an asset is the code, also known as an ID. To begin, copy and paste this into the opened simpleshinyblock file.<syntaxhighlight lang="json">
{
{
Line 52: Line 59:
</syntaxhighlight>Notice that each property is seperated using a comma. The new property, ''"creativeinventory"'' tells the game what creative tab this block will be placed in. The syntax of this particular property is a little bit more complex, but don't worry about it for now. All this does is add the block into the "general" creative tab.
</syntaxhighlight>Notice that each property is seperated using a comma. The new property, ''"creativeinventory"'' tells the game what creative tab this block will be placed in. The syntax of this particular property is a little bit more complex, but don't worry about it for now. All this does is add the block into the "general" creative tab.


<!--T:14-->
If you were to launch Vintage Story and enable your mod, you will see the block in the creative menu!  
If you were to launch Vintage Story and enable your mod, you will see the block in the creative menu!  


<!--T:15-->
[[File:SimpleBlockTutorialNoShapeOrTextureCreativeMenu.png|frameless|300x300px]]
[[File:SimpleBlockTutorialNoShapeOrTextureCreativeMenu.png|frameless|300x300px]]


<!--T:16-->
You can also place your block in the world!
You can also place your block in the world!


<!--T:17-->
[[File:SimpleBlockTutorialNoShapeNoTexture.png|frameless|300x300px]]
[[File:SimpleBlockTutorialNoShapeNoTexture.png|frameless|300x300px]]


Obviously, this is not the correct texture for the block.
Obviously, this is not the correct texture for the block.
== Adding the Shape & Texture ==
== Adding the Shape & Texture == <!--T:18-->
The texture file exists in the assets, so why isn't the item being [[wikipedia:Software_rendering|rendered]] correctly?
The texture file exists in the assets, so why isn't the item being [[wikipedia:Software_rendering|rendered]] correctly?


<!--T:19-->
For blocks to use a certain texture, then it must specify this within its json file. Replace your current blocktype json with the following:<syntaxhighlight lang="json">
For blocks to use a certain texture, then it must specify this within its json file. Replace your current blocktype json with the following:<syntaxhighlight lang="json">
{
{
Line 75: Line 87:
</syntaxhighlight>Two new properties have been added: ''drawtype'' and ''texture''.  
</syntaxhighlight>Two new properties have been added: ''drawtype'' and ''texture''.  


<!--T:20-->
Although ''drawtype'' is not necessary to determine the shape of the block, it is a good idea to include this property, as you may change it in the future. Setting this to ''Cube'' tells the block to render as a cube shape.  
Although ''drawtype'' is not necessary to determine the shape of the block, it is a good idea to include this property, as you may change it in the future. Setting this to ''Cube'' tells the block to render as a cube shape.  


<!--T:21-->
''Texture'' assigns and maps the texture to the block - Nothing special here.   
''Texture'' assigns and maps the texture to the block - Nothing special here.   


<!--T:22-->
If you run the game again, your block will now have the appropriate texture.
If you run the game again, your block will now have the appropriate texture.


<!--T:23-->
[[File:SimpleBlockTutorialGoldBlockWithShapeAndTexture.png|border|frameless|347x347px]]
[[File:SimpleBlockTutorialGoldBlockWithShapeAndTexture.png|border|frameless|347x347px]]


== Block Properties and Sounds ==
== Block Properties and Sounds == <!--T:24-->
There are a couple more changes that need to be made for your block to be finished.   
There are a couple more changes that need to be made for your block to be finished.   


<!--T:25-->
The first thing to set is the mining properties for your block. Add a comma after the last property, and add the following properties to your json file: <syntaxhighlight lang="json">
The first thing to set is the mining properties for your block. Add a comma after the last property, and add the following properties to your json file: <syntaxhighlight lang="json">
"blockmaterial": "Stone",
"blockmaterial": "Stone",
Line 91: Line 108:
</syntaxhighlight>The ''blockmaterial'' property determines what tools are effective at digging this block. Setting this to ''Stone'' implies that it can be mined by pickaxes. For a complete list of block materials, view the [https://github.com/anegostudios/vsapi/blob/a6adf202829e762f5e0397725fd462329d746f33/Common/Collectible/Block/EnumBlockMaterial.cs#L10 ''EnumBlockMaterial'' section on GitHub].
</syntaxhighlight>The ''blockmaterial'' property determines what tools are effective at digging this block. Setting this to ''Stone'' implies that it can be mined by pickaxes. For a complete list of block materials, view the [https://github.com/anegostudios/vsapi/blob/a6adf202829e762f5e0397725fd462329d746f33/Common/Collectible/Block/EnumBlockMaterial.cs#L10 ''EnumBlockMaterial'' section on GitHub].


<!--T:26-->
The ''resistance'' property determines how long a block takes to destroy, in seconds, without the use of a tool. Keep in mind that if the player uses a tool that affects the block material, the block will be destroyed faster.  
The ''resistance'' property determines how long a block takes to destroy, in seconds, without the use of a tool. Keep in mind that if the player uses a tool that affects the block material, the block will be destroyed faster.  


<!--T:27-->
To see if the changes are correct, save the file and reload the world. You should notice that your block takes longer to destroy, unless mined with a pickaxe.
To see if the changes are correct, save the file and reload the world. You should notice that your block takes longer to destroy, unless mined with a pickaxe.


<!--T:28-->
You may also notice that your block doesn't sound very metallic - So let's fix that. Your final block json should look like the following:<syntaxhighlight lang="json">
You may also notice that your block doesn't sound very metallic - So let's fix that. Your final block json should look like the following:<syntaxhighlight lang="json">
{
{
Line 112: Line 132:
</syntaxhighlight>The ''sounds'' property is rather self-explanatory, but it is important to notice that you prefix the file locations with "''game:''". This is because the sound files are located within the base game, and are not added by your mod. Here, you are just assigning sounds for ''place'' and ''walk.'' The most common types of sound for blocks are ''place'', ''walk'', ''break'', and ''hit.''
</syntaxhighlight>The ''sounds'' property is rather self-explanatory, but it is important to notice that you prefix the file locations with "''game:''". This is because the sound files are located within the base game, and are not added by your mod. Here, you are just assigning sounds for ''place'' and ''walk.'' The most common types of sound for blocks are ''place'', ''walk'', ''break'', and ''hit.''


== Renaming the Block ==
== Renaming the Block == <!--T:29-->
Currently, every instance of the block is called ''<nowiki/>'simpleblock:block-simplegoldblock'.'' To fix this, you need to add an entry to the lang file. Open up the provided ''en.json'' language file, found in ''assets/simpleblock/lang.'' This is what the file should look like:<syntaxhighlight lang="json">
Currently, every instance of the block is called ''<nowiki/>'simpleblock:block-simplegoldblock'.'' To fix this, you need to add an entry to the lang file. Open up the provided ''en.json'' language file, found in ''assets/simpleblock/lang.'' This is what the file should look like:<syntaxhighlight lang="json">
{
{
Line 123: Line 143:
</syntaxhighlight>To speed up testing, if you still have Vintage Story open, you can use the command '<nowiki/>''.reload lang'<nowiki/>'' to reload all lang files. Hovering over your block should show that the lang file has taken effect.
</syntaxhighlight>To speed up testing, if you still have Vintage Story open, you can use the command '<nowiki/>''.reload lang'<nowiki/>'' to reload all lang files. Hovering over your block should show that the lang file has taken effect.


<!--T:30-->
[[File:SimpleGoldBlockTutorialInCreativeMenu.png|frameless]]
[[File:SimpleGoldBlockTutorialInCreativeMenu.png|frameless]]


== Conclusion ==
== Conclusion == <!--T:31-->
Congratulations, you have now created your first block! This tutorial should have given you greater understanding of blocks, textures, sounds and language files, as well as the basics of modding for Vintage Story!  
Congratulations, you have now created your first block! This tutorial should have given you greater understanding of blocks, textures, sounds and language files, as well as the basics of modding for Vintage Story!  


=== Next Steps... ===
=== Next Steps... === <!--T:32-->
If you want to test your knowledge, consider doing the tasks under the ''Going Further'' section below.
If you want to test your knowledge, consider doing the tasks under the ''Going Further'' section below.


<!--T:33-->
When you're ready, try out the next tutorial: [[Modding:Content Tutorial Simple Recipe|Simple Recipes]]. This will show you how to create recipes for the assets you have created.
When you're ready, try out the next tutorial: [[Modding:Content Tutorial Simple Recipe|Simple Recipes]]. This will show you how to create recipes for the assets you have created.


== Going Further ==
== Going Further == <!--T:34-->
Want to make some additional changes to this mod? Try and achieve the following things!
Want to make some additional changes to this mod? Try and achieve the following things!


<!--T:35-->
Change the color of the block
Change the color of the block
{| class="wikitable mw-collapsible mw-collapsed"
{| class="wikitable mw-collapsible mw-collapsed"
Line 168: Line 191:
|}
|}


<!--T:36-->
{{Navbox/contentmodding}}
{{Navbox/contentmodding}}
</translate>
</translate>
Confirmedusers
536

edits