Modding:Entity Json Properties: Difference between revisions

From Vintage Story Wiki
(Created page with "__NOTOC__ == Overview == A complete list of all available properties <table id="treeviewtable" class="table table-bordered tt-table" style='table-layout: fixed'> <tr style=...")
 
No edit summary
Line 41: Line 41:
     <td>true</td>
     <td>true</td>
     <td>If the item will be loaded or not. Can be used to temporarily remove the item.</td>
     <td>If the item will be loaded or not. Can be used to temporarily remove the item.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_variantgroups" data-tt-parent="root">VariantGroups</div></td>
    <td>array of object</td>
    <td>-</td>
    <td>Allows you define multiple variants of the same item.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_variantgroups_info" data-tt-parent="p_variantgroups" data-invisible="true"></div></td>
    <td colspan="3">
The variantgroups property allows you to define multiple variants of this item. All of them will have their unique pattern, which will be added to the item code.
An easy example would be a bowl, which can either be raw or burned:
<syntaxhighlight lang="json">
variantgroups: [
{ code:"type", states: ["raw", "burned"] },
],
</syntaxhighlight>
Meaning there will be two variants <code>bowl-raw</code> and <code>bowl-burned</code>.
----
It's also possible to define multiple groups.
<syntaxhighlight lang="json">
variantgroups: [
{ code:"state", states: ["closed", "opened"] },
{ code:"contents", states: ["empty", "cabbage"] },
],
</syntaxhighlight>
As a result you will have 2x2 groups, which will be added one after each other: <code>barrel-closed-empty</code>, <code>barrel-closed-cabbage</code>, <code>barrel-opened-empty</code> and <code>barrel-opened-cabbage</code>.
----
Additionally it is possible to refer to external lists (used for blocks) that are found in the worldproperties folder, such as <code>block/rock</code>, which contains all states of all rock types. This used for <code>gravel</code>, <code>sand</code> and <code>rock</code>. It's a good way to keep everything organized:
<syntaxhighlight lang="json">
variantgroups: [
{ loadFromProperties: "block/rock" },
],
</syntaxhighlight>
Here is a full list of all groups and their variants (you can also find them in the <code>assets/worldproperties</code> folder):
{{:json:block:worldvariantgroups}}
----
Futhermore there are two 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).
Let's take a look at a different example (flowerpot), which uses the <code>additive</code> combination mode:
<syntaxhighlight lang="json">
variantgroups: [
{ code: "type", states: ["raw"] },
{ code: "empty", states: ["empty"], combine: "additive" },
{ code: "flower", loadFromProperties: "block/flower", combine: "additive" },
{ code: "mushroom", loadFromProperties: "block/mushroom", combine: "additive" },
{ code: "sapling", loadFromProperties: "block/wood", combine: "additive" },
],
</syntaxhighlight>
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:
<syntaxhighlight lang="json">
variantgroups: [
{ code: "something", states: ["same", "different"] },
{ code: "type", states: ["raw", "baked"] },
{ code: "empty", states: ["red", "green"], "combine": "additive" },
],
</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>
    </td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_byType" data-tt-parent="root">(any) byType</div></td>
    <td>key: string; value: object</td>
    <td>-</td>
    <td>You can create properties for certain variants of the item.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_byType_info" data-tt-parent="p_byType" data-invisible="true"></div></td>
    <td colspan="3">
In order to define properties for specific variants you can add '''byType''' to the property name. This allows you to define it depending on the type and always follows the same syntax:
<syntaxhighlight lang="json">
(property)ByType: {
"selector": property,
"selector2": property2,
...
}
</syntaxhighlight>
If the selector matches the name of the variant the given property will be used. Keep in mind that only the first matching one will be used (everything below will be ignored).
A slab for example has two variants ('''up''', '''down'''), which have different collision boxes:
<syntaxhighlight lang="json">
collisionboxByType: {
"*-down": { x1: 0, y1: 0, z1: 0,  x2: 1, y2: 0.5, z2: 1 },
"*-up": { x1: 0, y1: 0.5, z1: 0,  x2: 1, y2: 1, z2: 1 }
},
</syntaxhighlight>
The char '''<code>*</code>''' stands for anything. In this case it ignores the code of the item.
Furthermore this opens up even more possbilities for more advanced selectors like this one for doors:
<code>*-north-*-opened-left</code>. This will ignore the second variantgroup. Additionally ByType can also be used for child properties:
<syntaxhighlight lang="json">
collisionboxnbox: {
x1: 0, y1: 0, z1: 0.875, x2: 1, y2: 1, z2: 1,
rotateYByType: {
"*-north-*-opened-left": 90,
"*-north-*-closed-left": 0,
"*-west-*-opened-left": 180,
"*-west-*-closed-left": 90,
"*-east-*-opened-left": 0,
"*-east-*-closed-left": 270,
"*-south-*-opened-left": 270,
"*-south-*-closed-left": 180,
"*-north-*-opened-right": 270,
"*-north-*-closed-right": 0,
"*-west-*-opened-right": 0,
"*-west-*-closed-right": 90,
"*-east-*-opened-right": 180,
"*-east-*-closed-right": 270,
"*-south-*-opened-right": 90,
"*-south-*-closed-right": 180
}
},
</syntaxhighlight>
</td>
  </tr>
  <tr>
    <td colspan="4" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>Specific</b></td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_class" data-tt-parent="root">Class</div></td>
    <td>string</td>
    <td>&quot;item&quot;</td>
    <td>The item class can add special functionalities for the item.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_class_info" data-tt-parent="p_class" data-invisible="true"></div></td>
    <td colspan="3">
It can be used to open guis or adding other extra functionality to the item. A complete tutorial of how to add your own class to the game can be found [[Advanced Items|here]].
</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_durability" data-tt-parent="root">Durability</div></td>
    <td>integer</td>
    <td>0</td>
    <td>How many uses does this item has when being used. Item disappears at durability 0.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_damagedby" data-tt-parent="root">DamagedBy</div></td>
    <td>array of string</td>
    <td>-</td>
    <td>From which damage sources does the item takes durability damage.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_damagedby_blockbreaking" data-tt-parent="p_damagedby">BlockBreaking</div></td>
    <td></td>
    <td>0</td>
    <td>Mining a block.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_damagedby_attacking" data-tt-parent="p_damagedby">Attacking</div></td>
    <td></td>
    <td>1</td>
    <td>Hitting an entity.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_damagedby_fire" data-tt-parent="p_damagedby">Fire</div></td>
    <td></td>
    <td>2</td>
    <td>Currently not used.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool" data-tt-parent="root">Tool</div></td>
    <td>string</td>
    <td>-</td>
    <td>If set, this item will be classified as given tool.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_knife" data-tt-parent="p_tool">Knife</div></td>
    <td></td>
    <td>0</td>
    <td>USed to break grass.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_pickaxe" data-tt-parent="p_tool">Pickaxe</div></td>
    <td></td>
    <td>1</td>
    <td>Can mine rock and other stone materials</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_axe" data-tt-parent="p_tool">Axe</div></td>
    <td></td>
    <td>2</td>
    <td>Useful for chopping trees.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_sword" data-tt-parent="p_tool">Sword</div></td>
    <td></td>
    <td>3</td>
    <td>No special abilities yet.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_shovel" data-tt-parent="p_tool">Shovel</div></td>
    <td></td>
    <td>4</td>
    <td>Mines dirt, sand and gravel really fast.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_hammer" data-tt-parent="p_tool">Hammer</div></td>
    <td></td>
    <td>5</td>
    <td>No special abilities yet.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_mallet" data-tt-parent="p_tool">Mallet</div></td>
    <td></td>
    <td>6</td>
    <td>No special abilities yet.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_spear" data-tt-parent="p_tool">Spear</div></td>
    <td></td>
    <td>7</td>
    <td>No special abilities yet.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_bow" data-tt-parent="p_tool">Bow</div></td>
    <td></td>
    <td>8</td>
    <td>No special abilities yet.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_sickle" data-tt-parent="p_tool">Sickle</div></td>
    <td></td>
    <td>9</td>
    <td>No special abilities yet.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_hoe" data-tt-parent="p_tool">Hoe</div></td>
    <td></td>
    <td>10</td>
    <td>No special abilities yet.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tool_saw" data-tt-parent="p_tool">Saw</div></td>
    <td></td>
    <td>11</td>
    <td>No special abilities yet.</td>
  </tr>
  <tr>
    <td colspan="4" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>Common</b></td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_creativeinventory" data-tt-parent="root">CreativeInventory</div></td>
    <td>key: string, value: string[]</td>
    <td>-</td>
    <td>In which creative inventory tabs the item should be visible in.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_creativeinventory_info" data-tt-parent="p_creativeinventory" data-invisible="true"></div></td>
    <td colspan="3">
There are several tabs to you can add your stuff. Note that general should always be included, since it should contain everything.
*general
*terrain
*flora
*construction
*decorative
*items
'''Rock''' adds all of it's variantions to general, terrain and construction:
<syntaxhighlight lang="json">
creativeinventory: { "general": ["*"], "terrain": ["*"], "construction": ["*"] },
</syntaxhighlight>
'''<code>*</code>''' reprents the variants which will be added. You can specify multiple and separate them with a comma. It follows the same way as the '''byType''' property.
A '''Torch''' on the other hand only adds the variation '''<code>up</code>''':
<syntaxhighlight lang="json">
creativeinventory: { "general": ["*-up"], "decorative": ["*-up"] },
</syntaxhighlight>
</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_maxstacksize" data-tt-parent="root">MaxStackSize</div></td>
    <td>integer</td>
    <td>64</td>
    <td>Determines the maximum amount you can stack the item in one slot.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_attackpower" data-tt-parent="root">AttackPower</div></td>
    <td>decimal number</td>
    <td>0.5</td>
    <td>The damage the deals when hitting an entity.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_attackrange" data-tt-parent="root">AttackRange</div></td>
    <td>decimal number</td>
    <td>1.5</td>
    <td>The maximum distance you can hit an entity.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_materialdensity" data-tt-parent="root">MaterialDensity</div></td>
    <td>integer</td>
    <td>9999</td>
    <td>Determines on whether an object floats on liquids or not.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_materialdensity_info" data-tt-parent="p_materialdensity" data-invisible="true"></div></td>
    <td colspan="3">
Water has a density of 1000, meaning everything below or equal will float on water. The same goes for lava which has a density of 5000.
</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_liquidselectable" data-tt-parent="root">LiquidSelectable</div></td>
    <td>boolean</td>
    <td>false</td>
    <td>If the item can select a liquid while holding it in hand.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_liquidselectable_info" data-tt-parent="p_liquidselectable" data-invisible="true"></div></td>
    <td colspan="3">
Used for buckets in order to fill it with water and to place waterlily on top of water.
</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_miningspeed" data-tt-parent="root">MiningSpeed</div></td>
    <td>key: string, value: decimal number</td>
    <td>-</td>
    <td>The mining speed for each material.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_miningspeed" data-tt-parent="root">MiningTier</div></td>
    <td>integer</td>
    <td>0</td>
    <td>Determines which blocks it can break. If the required miningtier is above the defined one there will be no drop from it.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_attributes" data-tt-parent="root">Attributes</div></td>
    <td>key: string, value: object</td>
    <td>-</td>
    <td>Custom Attributes that's always assiociated with this item.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_attributes_info" data-tt-parent="p_attributes" data-invisible="true"></div></td>
    <td colspan="3">
Extra attributes added to a item or block. Those are final and cannot be modified. It's a good way to keep things oragnized and and modifiable. The '''oreblastingbomb''' for example has attributes, which define its radius and type. These can be used by behaviors and blockentities:
<syntaxhighlight lang="json">
    attributes: {
"blastRadius": 4,
"blastType": 0,
},
</syntaxhighlight>
</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_combustibleprops" data-tt-parent="root">CombustibleProps</div></td>
    <td>object</td>
    <td>-</td>
    <td>Information about the items burnable states.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_burntemperature" data-tt-parent="p_combustibleprops">BurnTemperature</div></td>
    <td>integer</td>
    <td>-</td>
    <td>The temperature at which it burns.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_burnduration" data-tt-parent="p_combustibleprops">BurnDuration</div></td>
    <td>decimal number</td>
    <td>-</td>
    <td>For how long it burns.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_heatresistance" data-tt-parent="p_combustibleprops">HeatResistance</div></td>
    <td>integer</td>
    <td>500</td>
    <td>How many degrees celsius it can resists before it ignites.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_meltingpoint" data-tt-parent="p_combustibleprops">MeltingPoint</div></td>
    <td>integer</td>
    <td>-</td>
    <td>How many degrees celsius it takes to smelt/transform this into another. Only used when put in a stove and Melted is set.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_meltingduration" data-tt-parent="p_combustibleprops">MeltingDuration</div></td>
    <td>decimal number</td>
    <td>-</td>
    <td>For how many seconds the temperature has to be above the melting point until the item is smelted.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_smokelevel" data-tt-parent="p_combustibleprops">SmokeLevel</div></td>
    <td>decimal number</td>
    <td>1</td>
    <td>How much smoke this item produces when being used as fuel.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_smeltedratio" data-tt-parent="p_combustibleprops">SmeltedRatio</div></td>
    <td>integer</td>
    <td>1</td>
    <td>How many ores are required to produce one output stack.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_liquidlevel" data-tt-parent="p_combustibleprops">SmeltedStack</div></td>
    <td>object</td>
    <td>-</td>
    <td>If set, the block/item is smeltable in a furnace and this is the resulting itemstack once the MeltingPoint has been reached for the supplied duration.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_requirescontainer" data-tt-parent="p_combustibleprops">RequiresContainer</div></td>
    <td>boolean</td>
    <td>true</td>
    <td>If set, the block/item is smeltable in a furnace and this is the resulting itemstack once the MeltingPoint has been reached for the supplied duration.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_combustibleprops_info" data-tt-parent="p_combustibleprops" data-invisible="true"></div></td>
    <td colspan="3">
This property can be used to define a burning material. '''Plank''' for example can get on fire:
<syntaxhighlight lang="json">
    combustibleProps: {
        burnTemperature: 800,
        burnDuration: 12,
    },
</syntaxhighlight>
Futhermore it can be used to define smelting processes. An example would be an '''ingotmold''' which turns into an ingotmold-burned:
<syntaxhighlight lang="json">
    combustiblePropsByType: {
        "ingotmold-raw": {
            meltingPoint: 600,
            meltingDuration: 30,
            smeltedRatio: 1,
            smeltedStack: { type: "block", code: "ingotmold-burned" },
            requiresContainer: false
        }
    },
</syntaxhighlight>
</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_nutritionprops" data-tt-parent="root">NutritionProps</div></td>
    <td>object</td>
    <td>-</td>
    <td>Information about the items nutrients.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_nutritionprops_foodcategory" data-tt-parent="p_nutritionprops">FoodCategory</div></td>
    <td>string</td>
    <td>-</td>
    <td>Defines the type of food. It can be '''''fruit''''', '''''vegetable''''', '''''protein''''', '''''grain''''' and '''''dairy'''''.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_nutritionprops_saturation" data-tt-parent="p_nutritionprops">Saturation</div></td>
    <td>decimal number</td>
    <td>0</td>
    <td>How much saturation it can restore.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_nutritionprops_health" data-tt-parent="p_nutritionprops">Health</div></td>
    <td>decimal number</td>
    <td>0</td>
    <td>How much health it can restore.</td>
  </tr>
  <tr>
    <td colspan="4" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>Rendering</b></td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_textures" data-tt-parent="root">Textures</div></td>
    <td>string</td>
    <td>required</td>
    <td>The texture definitions for the item held in hand or dropped on the ground.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_shape" data-tt-parent="root">Shape</div></td>
    <td>object</td>
    <td>-</td>
    <td>The items shape. Empty for automatic shape based on the texture.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_guitransform" data-tt-parent="root">GuiTransform</div></td>
    <td>object</td>
    <td>item default</td>
    <td>Used for scaling, rotation or offseting the item when rendered in guis.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_fphandtransform" data-tt-parent="root">FpHandTransform</div></td>
    <td>object</td>
    <td>item default</td>
    <td>Used for scaling, rotation or offseting the item when rendered in the first person mode hand.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_tphandtransform" data-tt-parent="root">TpHandTransform</div></td>
    <td>object</td>
    <td>item default</td>
    <td>Used for scaling, rotation or offseting the item when rendered in the third person mode hand.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_groundtransform" data-tt-parent="root">GroundTransform</div></td>
    <td>object</td>
    <td>item default</td>
    <td>Used for scaling, rotation or offseting the rendered as a dropped item on the ground.</td>
   </tr>
   </tr>
  </table>
  </table>

Revision as of 10:10, 12 July 2018

Overview

A complete list of all available properties

Property Type Default Usage
json
Core (no byType available)
Code
string required A unique identifier for the item.

A domain prefix will be added dynamically depending on the location of the file. Every mod and VintageStory itself have a unique prefix.

For example the code stone turns into game:stone.

The code identifier has to be unique inside its domain. In theory there could be equal identifiers with different domain prefixes. Find out more about Domains.

Enabled
boolean true If the item will be loaded or not. Can be used to temporarily remove the item.


Icon Sign.png

Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.

Modding
Modding Introduction Getting Started Theme Pack
Content Modding Content Mods Developing a Content Mod Basic Tutorials Intermediate Tutorials Advanced Tutorials Content Mod Concepts
Code Modding Code Mods Setting up your Development Environment
Property Overview ItemEntityBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository