Creating Custom Blocks: Difference between revisions

From Eco - English Wiki
[unchecked revision][checked revision]
(Initial skeleton)
 
m (Started to add a few more steps to the tutorial.)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[File:Stained Glass Block.png|frame]]
This page will walk you through the basics of adding custom blocks to Eco utilizing the Glass models found already in the game to make a Green Stained Glass block. A completed tutorial can be [https://github.com/StrangeLoopGames/EcoModKit/tree/examples/Examples/Blockset here] as well as the asset files needed to complete this tutorial.
This page will walk you through the basics of adding custom blocks to Eco utilizing the Glass models found already in the game to make a Green Stained Glass block. A completed tutorial can be [https://github.com/StrangeLoopGames/EcoModKit/tree/examples/Examples/Blockset here] as well as the asset files needed to complete this tutorial.
https://github.com/StrangeLoopGames/EcoModKit/tree/main/Examples/Blockset
== Initial Scene Setup ==
Eco has special naming requirements for GameObjects within the mod scene. For blocks this involves a empty GameObject with the name "Blocks" and a BlockSetContainer attached. This object will contain all BlockSets used by your mod.
[[File:BlockSetContainerStructure.png|none|thumb|542x542px]]
== Creating your BlockSet ==
The first step to implementing a block into your new BlockSetContainer is by creating a BlockSet object inside the Unity asset explorer. A BlockSet represents one block type within the project. It contains the BlockBuilder objects used to represent each form of the new block as well as visual properties about how it should be rendered. To create a new BlockSet right click inside the Unity asset explorer and click Create -> VoxelEngine -> BlockSet. The name of the newly created BlockSet file is not important for the mod to function however for best practice it should be named similar to the internal or display name of the new block. Once the file is created attach it to the BlockSetContainer made in the previous step.
[[File:BlockSet Menu Location.png|none|thumb]]


https://github.com/StrangeLoopGames/EcoModKit/tree/examples/Examples/Blockset
== Creating your first BlockBuilder ==
[[File:Green Stained Glass BlockSet.png|thumb]]
A BlockBuilder represents a single form of a block inside Eco and defines the rules and meshes used to display it in the world. For the purposes of this tutorial we will be creating seven BlockBuilder objects for our new BlockSet. This list includes three block forms and four builders to represent the various stack states.
* GreenStainedGlassWindow
* GreenStainedGlassStacked1
* GreenStainedGlassStacked2
* GreenStainedGlassStacked3
* GreenStainedGlassStacked4
* GreenStainedGlassCube
* GreenStainedGlassFlatRoof


== Initial Scene Setup ==


== Creating your BlockSet ==
The naming of these block sets is important for the code step later in the tutorial. Eco associates client side object with code by matching the given name. To create the seven required BlockBuilders right click the Unity asset explorer and go to Create -> VoxelEngine -> CustomBuilder. Do this for all seven builders and name them matching the list above. Once you have all seven builders return to the BlockSet object you previously created and click "New Block" and assign your first BlockBuilder and repeat for all seven. The order in which these are added is not important.


=== Creating your first BlockBuilder ===
== Add Meshes and materials to Builders ==
For each block you created above select them and add your material just below where you assigned your builder.
[[File:UnityBlockMatScreen.png|none|thumb]]


== Common Bugs ==
== Common Bugs ==
Below are a list of common bugs encountered while making custom blocks/blocksets and how to solve them.
Below are a list of common bugs encountered while making custom blocks and how to solve them.
 
==== My block does not appear using the right mesh or in the spot I placed it. ====
==== My block does not appear using the right mesh or in the spot I placed it. ====
This should be automatically handled in 9.4's ModKit. However if the issue is still present uncheck the "Optimize Mesh Data" option inside Unity's Player Settings prior to exporting the mesh.
This should be automatically handled in 9.4's ModKit. However if the issue is still present uncheck the "Optimize Mesh Data" option inside Unity's Player Settings prior to exporting the mesh.  
[[File:OptimizeMeshData-Unity-PlayerSettings.png|none|thumb|462x462px]]
==== My block is changing changing between my material and a different material ====
This usually is caused by a conflicting name with a material inside the client. If this happens a simple rename of the material should resolve this. This is also true with similar issues relating to the block mesh.
[[Category:Modding]]
{{DEFAULTSORT:CreatingCustomBlocks}}

Latest revision as of 22:29, 1 February 2022

This page will walk you through the basics of adding custom blocks to Eco utilizing the Glass models found already in the game to make a Green Stained Glass block. A completed tutorial can be here as well as the asset files needed to complete this tutorial. https://github.com/StrangeLoopGames/EcoModKit/tree/main/Examples/Blockset

Initial Scene Setup[edit | edit source]

Eco has special naming requirements for GameObjects within the mod scene. For blocks this involves a empty GameObject with the name "Blocks" and a BlockSetContainer attached. This object will contain all BlockSets used by your mod.

Creating your BlockSet[edit | edit source]

The first step to implementing a block into your new BlockSetContainer is by creating a BlockSet object inside the Unity asset explorer. A BlockSet represents one block type within the project. It contains the BlockBuilder objects used to represent each form of the new block as well as visual properties about how it should be rendered. To create a new BlockSet right click inside the Unity asset explorer and click Create -> VoxelEngine -> BlockSet. The name of the newly created BlockSet file is not important for the mod to function however for best practice it should be named similar to the internal or display name of the new block. Once the file is created attach it to the BlockSetContainer made in the previous step.


Creating your first BlockBuilder[edit | edit source]

A BlockBuilder represents a single form of a block inside Eco and defines the rules and meshes used to display it in the world. For the purposes of this tutorial we will be creating seven BlockBuilder objects for our new BlockSet. This list includes three block forms and four builders to represent the various stack states.

  • GreenStainedGlassWindow
  • GreenStainedGlassStacked1
  • GreenStainedGlassStacked2
  • GreenStainedGlassStacked3
  • GreenStainedGlassStacked4
  • GreenStainedGlassCube
  • GreenStainedGlassFlatRoof


The naming of these block sets is important for the code step later in the tutorial. Eco associates client side object with code by matching the given name. To create the seven required BlockBuilders right click the Unity asset explorer and go to Create -> VoxelEngine -> CustomBuilder. Do this for all seven builders and name them matching the list above. Once you have all seven builders return to the BlockSet object you previously created and click "New Block" and assign your first BlockBuilder and repeat for all seven. The order in which these are added is not important.

Add Meshes and materials to Builders[edit | edit source]

For each block you created above select them and add your material just below where you assigned your builder.

Common Bugs[edit | edit source]

Below are a list of common bugs encountered while making custom blocks and how to solve them.

My block does not appear using the right mesh or in the spot I placed it.[edit | edit source]

This should be automatically handled in 9.4's ModKit. However if the issue is still present uncheck the "Optimize Mesh Data" option inside Unity's Player Settings prior to exporting the mesh.

My block is changing changing between my material and a different material[edit | edit source]

This usually is caused by a conflicting name with a material inside the client. If this happens a simple rename of the material should resolve this. This is also true with similar issues relating to the block mesh.