Modding:Entity Json Properties: Difference between revisions

From Vintage Story Wiki
no edit summary
No edit summary
No edit summary
Line 155: Line 155:
Can be used to add interaction to the entity or other special functionalities. Example uses are <code>EntityItem</code> and <code>EntityPlayer</code>.
Can be used to add interaction to the entity or other special functionalities. Example uses are <code>EntityItem</code> and <code>EntityPlayer</code>.
</td>
</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_habitat" data-tt-parent="root">Habitat</div></td>
    <td>string</td>
    <td>&quot;land&quot;</td>
    <td>There is <code>sea</code>, <code>land</code> and <code>air</code></td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_hitboxsize" data-tt-parent="root">HitBoxSize</div></td>
    <td>object</td>
    <td>x: 0.125, y: 0.125</td>
    <td>The size of the hitbox, either to hit the entity or to interact with it.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_eyeheight" data-tt-parent="root">EyeHeight</div></td>
    <td>decimal number</td>
    <td>0.1</td>
    <td>Height of the eyes, measured from the bottom of the hitbox in meters. Used for camera angle and various other things.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_canclimb" data-tt-parent="root">CanClimb</div></td>
    <td>boolean</td>
    <td>false</td>
    <td>Whether the entity can climb on ladders or other blocks which are climbable.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_canclimbanywhere" data-tt-parent="root">CanClimbAnywhere</div></td>
    <td>boolean</td>
    <td>false</td>
    <td>Whether the entity can climb on any block, doesn't matter if it's a ladder or not.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_falldamage" data-tt-parent="root">FallDamage</div></td>
    <td>boolean</td>
    <td>true</td>
    <td>Whether the entity will take fall damage.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_climbtouchdistance" data-tt-parent="root">ClimbTouchDistance</div></td>
    <td>decimal number</td>
    <td>0.5</td>
    <td>Distance at which the entity can climb on something.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_rotatemodelonclimb" data-tt-parent="root">RotateModelOnClimb</div></td>
    <td>boolean</td>
    <td>false</td>
    <td>If true the entity model will be rotated to face the block its climbing on.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_knockbackresistance" data-tt-parent="root">KnockbackResistance</div></td>
    <td>decimal number</td>
    <td>0.0</td>
    <td>The higher the number is the less knockback will be applied. Useful for heavy entities.</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 associated with this entity.</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 the entity. Those are final and cannot be modified. It's a good way to keep things organized and and modifiable. These can be used by behaviors or the entity class:
<syntaxhighlight lang="json">
    attributes: {
"attackPower": 10
},
</syntaxhighlight>
</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_sounds" data-tt-parent="root">Sounds</div></td>
    <td>key: string, value: string</td>
    <td>-</td>
    <td>Sounds of the entity, you can also add your own sounds and play them, but here is a list of default sounds used <code>death</code>, <code>hurt</code>, <code>idle</code>, <code>jump</code>, <code>swim</code> and <code>eat</code></td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_idlesoundchance" data-tt-parent="root">IdleSoundChance</div></td>
    <td>decimal number</td>
    <td>0.3</td>
    <td>How likely it is for the entity to play an idle sound.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_idlesoundrange" data-tt-parent="root">IdleSoundRange</div></td>
    <td>decimal number</td>
    <td>24</td>
    <td>How far the idle sound played by the entity can be heard.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_drops" data-tt-parent="root">Drops</div></td>
    <td>array of object</td>
    <td>-</td>
    <td>The items that should drop from breaking this block.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_drops_info" data-tt-parent="p_drops" data-invisible="true"></div></td>
    <td colspan="3">
'''No drop'''
By default an entity does not drop anything at all:
<syntaxhighlight lang="json">
drops: [],
</syntaxhighlight>
----
'''Drop'''
You can also specify an item or block to drop. Therefore you need to define an '''ItemStack''', with the given properties:
<table class="wikitable">
  <tr style="background-color: grey;">
    <th style="background-color: grey;">Property</th>
    <th style="background-color: grey;">Default</th>
<th style="background-color: grey;">Explanation</th>
  </tr>
  <tr>
    <td>'''type'''</td>
<td>''block''</td>
<td>Can either be '''''block''''' or '''''item'''''.</td>
  </tr>
  <tr>
    <td>'''code''' (required)</td>
<td>-</td>
<td>The complete code (can also include domain) of the item or block.</td>
  </tr>
  <tr>
    <td>'''lastdrop'''</td>
<td>false</td>
<td>If true and the quantity dropped is >=1 any subsequent drop in the list will be ignored.</td>
  </tr>
  <tr>
    <td>'''attributes'''</td>
<td>-</td>
<td>Tree Attributes that will be attached to the resulting itemstack.</td>
  </tr>
  <tr>
    <td>'''tool'''</td>
<td>-</td>
<td>If specified then given tool is required to break this block.</td>
  </tr>
  <tr>
    <td>'''quantity'''</td>
<td>- (one)</td>
<td>Determines the quantity of items which will be dropped.</td>
  </tr>
</table>
For example, if the entity should drop '''charcoalpile''':
<syntaxhighlight lang="json">
drops: [
{ type: "item", code: "charcoal" }
],
</syntaxhighlight>
You can also specify drop special itemstack if the entity is killed by certain tool, similar to '''Tallgrass''' which only drops something if it's mined by a knife:
<syntaxhighlight lang="json">
drops: [
{ type: "item", code: "drygrass", tool: "knife"  },
],
</syntaxhighlight>
----
'''Chance drops'''
Let's take a look at an example. This is the drop property of rock:
<syntaxhighlight lang="json">
drops: [
{
type: "item",
code: "stone-{rock}",
quantity: { avg: 2.5, var: 0.5 }
},
]
</syntaxhighlight>
This will drop 2-3 blocks.
'''''avg''''': Stands for the default drop quantity. If var is 0 or not specified it will always drop the given average.
'''''var''''': How much the drop rate can vary. Meaning the drop rate can be <code>avg - var</code> at minimum and <code>age + var</code> at maximum.
Furthermore you can also switch between different distribution modes using the '''''dist''''' property.
<table class="wikitable mw-collapsible mw-collapsed">
  <tr>
<th colspan="2">Overview - Distribution modes</th>
  </tr>
  <tr style="background-color: grey;">
    <th style="background-color: grey;">Name</th>
<th style="background-color: grey;">Explanation</th>
  </tr>
  <tr>
    <td>'''uniform'''</td>
<td>''Select completely random numbers within avg-var until avg+var.''</td>
  </tr>
  <tr>
    <td>'''triangle'''</td>
<td>''Select random numbers with numbers near avg being the most commonly selected ones, following a triangle curve.''</td>
  </tr>
  <tr>
    <td>'''gaussian'''</td>
<td>''Select random numbers with numbers near avg being the most commonly selected ones, following a gaussian curve.''</td>
  </tr>
  <tr>
    <td>'''narrowgaussian'''</td>
<td>''Select random numbers with numbers near avg being the most commonly selected ones, following a narrow gaussian curve.''</td>
  </tr>
  <tr>
    <td>'''inversegaussian'''</td>
<td>''Select random numbers with numbers near avg being the least commonly selected ones, following an upside down gaussian curve.''</td>
  </tr>
  <tr>
    <td>'''narrowinversegaussian'''</td>
<td>''Select random numbers with numbers near avg being the least commonly selected ones, following an upside down gaussian curve.''</td>
  </tr>
  <tr>
    <td>'''invexp'''</td>
<td>''Select numbers in the form of avg + var, wheras low value of var are preferred.''</td>
  </tr>
  <tr>
    <td>'''stronginvexp'''</td>
<td>''Select numbers in the form of avg + var, wheras low value of var are strongly preferred.''</td>
  </tr>
  <tr>
    <td>'''strongerinvexp'''</td>
<td>''Select numbers in the form of avg + var, wheras low value of var are very strongly preferred.''</td>
  </tr>
<tr>
    <td>'''dirac'''</td>
<td>''Select completely random numbers within avg-var until avg+var only ONCE and then always 0.''</td>
  </tr>
</table>
----
'''Multiple Drops'''
Of course you can also define multiple drops at once. A '''Sapling''' for example can drop a sapling and a stick:
<syntaxhighlight lang="json">
drops: [
{
type: "block",
code: "sapling-{wood}",
quantity: { avg: 0.02, var: 0 },
},
{
type: "item",
code: "stick",
quantity: { avg: 0.02, var: 0 },
}
],
</syntaxhighlight>
----
'''Last Drop'''
In order to add a special drop, which (if dropped) prevents all other drops, you can use the lastDrop property:
<syntaxhighlight lang="json">
drops: [
{ type: "item", code: "stick",  quantity: { avg: 0.2, var: 0 }, lastDrop: true },
{ type: "item", code: "sapling",  quantity: { avg: 1.25, var: 0 }  }
],
</syntaxhighlight>
The entity will either drop a stick with a chance of 20% or an average of 1.25 saplings.
</td>
  </tr>
  <tr>
    <td colspan="4" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>client: {</b></td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_renderer" data-tt-parent="root">Renderer</div></td>
    <td>string</td>
    <td>-</td>
    <td>Name of there renderer system that draws this entity.</td>
  </tr>
  <tr>
    <td colspan="4" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>}</b></td>
  </tr>
  <tr>
    <td colspan="4" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>server: {</b></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 associated with this entity only known by the server. They will not be send to the client.</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 the entity for server use only. Those are final and cannot be modified. It's a good way to keep things organized and and modifiable. These can be used by behaviors or the entity class:
<syntaxhighlight lang="json">
    attributes: {
"attackPower": 10
},
</syntaxhighlight>
</td>
  </tr>
  <tr>
    <td colspan="4" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>}</b></td>
   </tr>
   </tr>
  </table>
  </table>
Confirmedusers, editor, Administrators
886

edits