Modding:Block Json Properties: Difference between revisions

From Vintage Story Wiki
Fix BlockEntityBehaviors link
(Fix BlockEntityBehaviors link)
(6 intermediate revisions by 4 users not shown)
Line 79: Line 79:
An easy example would be a bowl, which can either be raw or burned:
An easy example would be a bowl, which can either be raw or burned:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
code: "bowl",
variantgroups: [
variantgroups: [
{ code:"type", states: ["raw", "burned"] },
{ code:"type", states: ["raw", "burned"] },
Line 91: Line 92:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
code: "barrel",
variantgroups: [
variantgroups: [
{ code:"state", states: ["closed", "opened"] },
{ code:"state", states: ["closed", "opened"] },
Line 113: Line 115:
----
----


Furthermore there are other ways of combining groups together. So far we covered the default combination mode, which is <code>multiplicative</code> (the total count of variants is the product of all states). There are two other methods, Additive and SelectiveMultiply.  
Furthermore there are other ways of combining groups together. So far we covered the default combination mode, which is <code>Multiply</code> (the total count of variants is the product of all states). There are two other methods, Add and SelectiveMultiply.  


Let's take a look at the <code>additive</code> combination mode used in the flowerpot block:
Let's take a look at the <code>Add</code> combination mode used in this example of a flowerpot block:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
code: "flowerpot",
variantgroups: [
variantgroups: [
{ code: "type", states: ["raw"] },
{ code: "type", states: ["raw"] },
{ code: "empty", states: ["empty"], combine: "additive" },
{ code: "empty", states: ["empty"], combine: "Add" },
{ code: "flower", loadFromProperties: "block/flower", combine: "additive" },
{ code: "flower", loadFromProperties: "block/flower", combine: "Add" },
{ code: "mushroom", loadFromProperties: "block/mushroom", combine: "additive" },
{ code: "mushroom", loadFromProperties: "block/mushroom", combine: "Add" },
{ code: "sapling", loadFromProperties: "block/wood", combine: "additive" },
{ code: "sapling", loadFromProperties: "block/wood", combine: "Add" },
],
],
</syntaxhighlight>
</syntaxhighlight>
Line 129: Line 132:
The variants are <code>flowerpot-raw</code>, <code>flowerpot-empty</code>, <code>flowerpot-{all flowers}</code>, <code>flowerpot-{all mushrooms}</code> and <code>flowerpot-{all saplings}</code>.
The variants are <code>flowerpot-raw</code>, <code>flowerpot-empty</code>, <code>flowerpot-{all flowers}</code>, <code>flowerpot-{all mushrooms}</code> and <code>flowerpot-{all saplings}</code>.


<code>Additive</code> mode could also be called separate, since it defines a variant separate from all the other groups:
<code>Add</code> mode could also be called separate, since it defines a variant separate from all the other groups:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
code: "thingy",
variantgroups: [
variantgroups: [
{ code: "something", states: ["same", "different"] },
{ code: "something", states: ["same", "different"] },
{ code: "type", states: ["raw", "baked"] },
{ code: "type", states: ["raw", "baked"] },
{ code: "empty", states: ["red", "green"], "combine": "additive" },
{ code: "empty", states: ["red", "green"], "combine": "Add" },
],
],
</syntaxhighlight>
</syntaxhighlight>


In this case, the result would be <code>same-raw</code>, <code>same-baked</code>, <code>different-raw</code>, <code>different-baked</code>, <code>red</code> and <code>green</code>
In this case, the result would be <code>thingy-same-raw</code>, <code>thingy-same-baked</code>, <code>thingy-different-raw</code>, <code>thingy-different-baked</code>, <code>thingy-red</code> and <code>thingy-green</code>


The third combination mode <code>"SelectiveMultiply"</code> which allows you to specify which variant groups you want to combine multiplicatively with. There are many examples of this in the clothing item JSONS, as shown below with the lowerbody asset:
The third combination mode <code>"SelectiveMultiply"</code> which allows you to specify which variant groups you want to combine multiplicatively with. There are many examples of this in the clothing item JSONS, as shown below with this example of a lowerbody asset:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
Line 153: Line 157:
</syntaxhighlight>
</syntaxhighlight>


The function <code>onVariant</code> specifies which variant group to selectively combine with, ignoring all other variants without it (in case some are combined additively).  
The parameter <code>onVariant</code> specifies which variant group (by using that groups <code>code</code>) to target and the <code>code</code> specifies which of the target variant groups <code>states</code> (only one) to selectively combine with, ignoring all other variants without that specific state.  


Using this will result items called <code>clothes-lowerbody-aristocrat-leggings</code>, <code>clothes-lowerbody-dirty-linen-trousers</code>, etc.
Using this will result items called <code>clothes-lowerbody-aristocrat-leggings</code>, <code>clothes-lowerbody-dirty-linen-trousers</code>, etc.
'''Variant group placeholder:'''
Since Vintagestory v1.8 it is also possible to use the variantgroups codes as placeholders (<code>{variant_group_code}</code>) in for example paths to textures.:
<syntaxhighlight lang="json">
code: "axe",
variantgroups: [
{ code: "metal", states: ["copper", "tinbronze", "bismuthbronze", "blackbronze", "gold", "silver", "iron" ] },
],
textures: {
"metal": { base: "block/metal/ingot/{metal}" },
"wood": { base: "item/tool/material/wood" }
},
</syntaxhighlight>
Now the <code>metal</code> texture path will change based on the variant. For example the variant <code>axe-copper</code> will use <code>block/metal/ingot/copper</code> as its <code>metal</code> texture.


     </td>
     </td>
Line 218: Line 238:
</syntaxhighlight>
</syntaxhighlight>


Since Vintagestory v1.8 it is also possible to use the variantgroup as a placeholder:
    </td>
  </tr>
<tr>
  <td scope="row"><div class="tt" data-tt-id="p_allowedVariants" data-tt-parent="root">allowedVariants</div></td>
  <td>array of strings</td>
  <td>-</td>
  <td>Used to trim unnecessary items generated by combined variants. </td>
  <td>crystalizedore-graded, ore-graded, ore-ungraded</td>
</tr>
<tr>
    <td scope="row"><div class="tt" data-tt-id="p_allowedVariants_info" data-tt-parent="p_allowedVariants" data-invisible="true"></div></td>
    <td colspan="4">
By using the <code>allowedVariants</code> you can specify which variants you want to be generated. Looks at this example of different armor parts (uses both <code>allowedVariants</code> and <code>skipVariants</code>):
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
code: "armor",
variantgroups: [
variantgroups: [
{ code: "metal", states: ["copper", "tinbronze", "bismuthbronze", "blackbronze", "gold", "silver", "iron" ] },
{ code: "bodypart", states: ["head", "body", "legs"] },
{ code: "construction",  states: [
"improvised",
"jerkin",
"lamellar",
"sewn",
"brigandine",
"chain",
"scale",
"plate"
]},
{ code: "material", states: [
"wood",
"leather",
"linen",
"copper",
"tinbronze",
"bismuthbronze",
"blackbronze",
"iron",
"steel",
"gold",
"silver"
]},
],
skipVariants: [
"armor-*-brigandine-leather",
"armor-*-brigandine-linen",
"armor-*-brigandine-wood",
"armor-*-brigandine-gold",
"armor-*-brigandine-silver",
"armor-*-chain-leather",
"armor-*-chain-linen",
"armor-*-chain-wood",
"armor-*-scale-leather",
"armor-*-scale-linen",
"armor-*-scale-wood",
"armor-*-scale-gold",
"armor-*-scale-silver",
"armor-*-plate-leather",
"armor-*-plate-linen",
"armor-*-plate-wood",
"armor-*-sewn-wood",
],
],
textures: {
allowedVariants: [
"metal": { base: "block/metal/ingot/{metal}" },
"armor-body-improvised-wood",
"wood": { base: "item/tool/material/wood" }
},
"armor-body-jerkin-leather",
</syntaxhighlight>
"armor-legs-jerkin-leather",
</td>
"armor-*-lamellar-wood",
"armor-*-lamellar-copper",
"armor-*-lamellar-tinbronze",
"armor-*-lamellar-bismuthbronze",
"armor-*-lamellar-blackbronze",
 
"armor-*-sewn-linen",
"armor-*-sewn-leather",
"armor-*-scale-*",
"armor-*-chain-*",
"armor-*-plate-*",
"armor-*-brigandine-*",
],</syntaxhighlight>
 
The wildcard char '''<code>*</code>''' stands for anything, and can be used to target many variants with one string instead of having to write them all down.
    </td>
   </tr>
   </tr>
  <tr>
  <td scope="row"><div class="tt" data-tt-id="p_enabled" data-tt-parent="root">allowedVariants</div></td>
  <td>array of objects</td>
  <td>-</td>
  <td>Used to trim unnecessary items generated by combined variants. </td>
  <td>crystalizedore-graded, ore-graded, ore-ungraded</td>
</tr>
<tr>
<tr>
   <td scope="row"><div class="tt" data-tt-id="p_enabled" data-tt-parent="root">skipVariants</div></td>
   <td scope="row"><div class="tt" data-tt-id="p_skipVariants" data-tt-parent="root">skipVariants</div></td>
   <td>array of object</td>
   <td>array of strings</td>
   <td>-</td>
   <td>-</td>
   <td>Similar to allowedVariants, but instead skips the creation of listed variants rather than assigning which are allowed. </td>
   <td>Similar to allowedVariants, but instead skips the creation of listed variants rather than assigning which are allowed. </td>
   <td>armor</td>
   <td>armor</td>
</tr>
</tr>
<tr>
    <td scope="row"><div class="tt" data-tt-id="p_skipVariants_info" data-tt-parent="p_skipVariants" data-invisible="true"></div></td>
    <td colspan="4">
By using the <code>skipVariants</code> you can specify which variants you do NOT want to be generated. For an example look above under <code>allowedVariants</code> which shows both <code>allowedVariants</code> and <code>skipVariants</code> in use at the same time.
    </td>
  </tr>
   <tr>
   <tr>
     <td colspan="5" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>Specific</b></td>
     <td colspan="5" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>Specific</b></td>
Line 293: Line 386:
Block entity behaviors are expanded capabilities that regular behaviors cannot accomplish. At the moment they are only used for Mechanical Power blocks, but if you're looking to make your own you can look through the existing files at the Vintage Story Github [https://github.com/anegostudios/vssurvivalmod/tree/master/Systems/MechanicalPower/BlockEntityBehavior here ].
Block entity behaviors are expanded capabilities that regular behaviors cannot accomplish. At the moment they are only used for Mechanical Power blocks, but if you're looking to make your own you can look through the existing files at the Vintage Story Github [https://github.com/anegostudios/vssurvivalmod/tree/master/Systems/MechanicalPower/BlockEntityBehavior here ].


To see all of the current block entity behaviors in the game see [[Json:block:behaviors|All Block Behaviors]].
To see all of the current block entity behaviors in the game see [[Modding:Block_Entity_Behaviors|All Block Entity Behaviors]].
</td>
</td>
   </tr>
   </tr>
Line 2,508: Line 2,601:
   <tr>
   <tr>
     <td scope="row"><div class="tt" data-tt-id="p_ao_info" data-tt-parent="p_sideao" data-invisible="true"></div></td>
     <td scope="row"><div class="tt" data-tt-id="p_ao_info" data-tt-parent="p_sideao" data-invisible="true"></div></td>
    <td colspan="4">
Sides include: ''all; horizontals, verticals; east, west, up, down, north, south''.
  </tr>
<tr>
    <td scope="row"><div class="tt" data-tt-id="p_sideemitao" data-tt-parent="root">sideEmitAo</div></td>
    <td>key: string, value: boolean</td>
    <td>-</td>
    <td>Defines which of the 6 block neighbours should receive AO if this block is in front of them.</td>
    <td>-</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_sideemitao_info" data-tt-parent="p_sideemitao" data-invisible="true"></div></td>
     <td colspan="4">
     <td colspan="4">
Sides include: ''all; horizontals, verticals; east, west, up, down, north, south''.  
Sides include: ''all; horizontals, verticals; east, west, up, down, north, south''.  
Line 2,531: Line 2,636:
   </tr>
   </tr>
   <tr>
   <tr>
     <td scope="row"><div class="tt" data-tt-id="p_randomrotations" data-tt-parent="root">randomRotations</div></td>
     <td scope="row"><div class="tt" data-tt-id="p_randomrotations" data-tt-parent="root">randomizeRotations</div></td>
     <td>boolean</td>
     <td>boolean</td>
     <td>false</td>
     <td>false</td>
     <td>If true then the block will be randomly rotated when placed.</td>
     <td>If true then the block will be randomly rotated when placed. Note: Many random rotated blocks in one chunk will slow down block placement updates. You can increase efficieny by defining alternate shapes with random rotations instead.</td>
     <td>flower</td>
     <td>flower</td>
   </tr>
   </tr>
Confirmedusers, editor
749

edits