Modding:Entity Behaviors: Difference between revisions
(add using section) |
(→All Behaviors: fix the sides of the behaviors) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Using Entity Behaviors == | == Using Entity Behaviors == | ||
Inside the entity json file, entity behaviors can be added to the '''client''' section, '''server''' section, or both. For example, here is the '''controlledphysics''' behavior from <code>deer.json</code>, added to both the '''client''' and '''server''' sections. This shows the pre-1.20 style of including the behavior on both sides. Note that the properties are added directly to the behavior object, instead of in a properties object like with blocks and items. | Inside the entity json file, entity behaviors can be added to the '''client''' section, '''server''' section, or both. For example, here is the '''controlledphysics''' behavior from <code>deer.json</code>, added to both the '''client''' and '''server''' sections. This shows the pre-1.20 style of including the behavior on both sides. Note that the properties are added directly to the behavior object, instead of in a properties object like with blocks and items. Also note that the builtin entity behavior names are all lower case, unlike block and collectible behaviors. | ||
<syntaxhighlight lang="json"> | <syntaxhighlight lang="json"> | ||
client: { | client: { | ||
Line 70: | Line 70: | ||
}, | }, | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== All Behaviors == | |||
Here is a table containing all the entity behaviors of the base game. Of course mods can, and are encouraged to add new behaviors. | |||
{| class="wikitable" | |||
|- | |||
! Behavior Name | |||
! Explanation | |||
! style="width: 8em" |Example entities | |||
! style="width: 15em" |Properties | |||
! Side | |||
|- | |||
| [[Modding:Entity_Behavior_aimingaccuracy|aimingaccuracy]] | |||
| Adds aiming inaccuracy when sprinting, jumping, etc. | |||
| | |||
* player | |||
* playerbot | |||
| | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_breathe|breathe]] | |||
| The entity will need to breathe and therefore suffocate in other blocks (for example sand). | |||
| | |||
* player - both sides | |||
* most animals - server only | |||
| | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_collectitems|collectitems]] | |||
| The entity collections items laying around on the ground. | |||
| | |||
* player | |||
* bot | |||
* racoon | |||
| | |||
| Server | |||
|- | |||
| [[Modding:Entity_Behavior_controlledphysics|controlledphysics]] | |||
| Add physics to the entity. | |||
| | |||
* most entities | |||
| | |||
stepHeight = 0.6 | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_despawn|despawn]] | |||
| The entity will despawn under given circumstances. | |||
| | |||
* projectiles - server only | |||
* animals - both sides | |||
| | |||
minPlayerDistance<br/> | |||
belowLightLevel<br/> | |||
minSeconds = 30<br/> | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_emotionstates|emotionstates]] | |||
| Adds emotion states with a given chance. As an example, it can be used to make an animal "hungry" (aggressive) and "saturated" (passive). | |||
| | |||
* most animals | |||
* most humanoids | |||
| | |||
states<br/> | |||
| Server | |||
|- | |||
| [[Modding:Entity_Behavior_floatupwhenstuck|floatupwhenstuck]] | |||
| Float up the entity if it gets stuck in a block. | |||
| | |||
* item | |||
* most animals | |||
| | |||
onlyWhenDead = false<br/> | |||
pushVelocityMul = 1<br/> | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_grow|grow]] | |||
| The entity will grow and eventually turn into one of its adults. | |||
| | |||
* pig-wild-piglet | |||
* most baby animals | |||
| | |||
hoursToGrow = 96<br/> | |||
adultEntityCodes = []<br/> | |||
| Server | |||
|- | |||
| [[Modding:Entity_Behavior_health|health]] | |||
| Applies custom health to the entity. Means the entity can be hurt as well. | |||
| | |||
* bear | |||
* player | |||
* most entities | |||
| | |||
currenthealth = 20<br/> | |||
maxhealth = 20<br/> | |||
basemaxhealth = 20<br/> | |||
| Server | |||
|- | |||
| [[Modding:Entity_Behavior_hunger|hunger]] | |||
| Adds saturation and hunger, the entity needs to eat in order to stay alive. | |||
| | |||
* player | |||
| | |||
currentsaturation = 1200 | |||
maxsaturation = 1200 | |||
saturationlossdelay = 60 * 24 | |||
currentfruitLevel = 0 | |||
currentvegetableLevel = 0 | |||
currentgrainLevel = 0 | |||
currentproteinLevel = 0 | |||
currentdairyLevel = 0 | |||
| Server | |||
|- | |||
| [[Modding:Entity_Behavior_interpolateposition|interpolateposition]] | |||
| Interpolates entity position and rotate. Smooths out the animations. It's a visual effect, therefore not available on server side. | |||
| | |||
* most entities | |||
| | |||
| Client | |||
|- | |||
| [[Modding:Entity_Behavior_multiply|multiply]] | |||
| A pack of wolves for example grows in size over time (new babies are born). When installed on the client side, it shows portions eaten info text. | |||
| | |||
* hostile animals - server only | |||
* farm animals - both sides | |||
| | |||
pregnancyDays = 3.0<br/> | |||
spawnEntityCode<br/> | |||
requiresNearbyEntityCode<br/> | |||
requiresNearbyEntityRange = 5<br/> | |||
multiplyCooldownDaysMin = 6<br/> | |||
multiplyCooldownDaysMax = 12<br/> | |||
portionsEatenForMultiply = 3<br/> | |||
spawnQuantityMin = 1<br/> | |||
spawnQuantityMax = 2<br/> | |||
requiresFood = true | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_nametag|nametag]] | |||
| Adds a name tag to the entity which will be displayed above the entity. | |||
| | |||
* player | |||
* playerbot | |||
* trader | |||
* villager | |||
| | |||
renderRange = 99<br/> | |||
selectFromRandomName<br/> | |||
showtagonlywhentargeted = false<br/> | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_passivephysics|passivephysics]] | |||
| Adds physics to the entity. | |||
| | |||
* item | |||
* thrownstone | |||
* most projectiles | |||
| | |||
waterDragFactor = 1<br/> | |||
airDragFallingFactor = 1<br/> | |||
groundDragFactor = 1<br/> | |||
gravityFactor = 1<br/> | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_placeblock|placeblock]] | |||
| The entity will place one of the given block codes from time to time. | |||
| | |||
* hen - prior to 1.15 update | |||
| | |||
minHourDelay = 8 * 24<br/> | |||
maxHourDelay = 15*24<br/> | |||
blockCodes = []<br/> | |||
| Server | |||
|- | |||
| [[Modding:Entity_Behavior_playerphysics|playerphysics]] | |||
| Makes an entity controllable by a player. Because this inherits from controlledphysics, do not add both to an entity. | |||
| | |||
* player | |||
| | |||
stepHeight = 0.6 | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_repulseagents|repulseagents]] | |||
| Pushes other entities back. | |||
| | |||
* most entities | |||
| | |||
* movable = true | |||
| Universal | |||
|- | |||
| [[Modding:Entity_Behavior_taskai|taskai]] | |||
| Allows you to specify tasks. | |||
| | |||
* most entities | |||
| | |||
aitasks | |||
| Server | |||
|- | |||
| [[Modding:Entity_Behavior_tiredness|tiredness]] | |||
| The entity will get tired over time. When it is sufficiently tired, it may sleep in a bed. | |||
| | |||
* player | |||
| | |||
currenttiredness = 0</br> | |||
| Universal | |||
|} |
Revision as of 05:17, 6 October 2024
Using Entity Behaviors
Inside the entity json file, entity behaviors can be added to the client section, server section, or both. For example, here is the controlledphysics behavior from deer.json
, added to both the client and server sections. This shows the pre-1.20 style of including the behavior on both sides. Note that the properties are added directly to the behavior object, instead of in a properties object like with blocks and items. Also note that the builtin entity behavior names are all lower case, unlike block and collectible behaviors.
client: {
...
behaviors: [
...
{
code: "controlledphysics",
"stepHeightByType": {
"deer-pampas-*": 2.1251,
"deer-pudu-*": 2.1251,
"deer-redbrocket-*": 2.1251,
"*": 3.1251
}
},
...
],
...
},
server: {
...
behaviors: [
...
{
code: "controlledphysics",
"stepHeightByType": {
"deer-pampas-*": 2.1251,
"deer-pudu-*": 2.1251,
"deer-redbrocket-*": 2.1251,
"*": 3.1251
}
},
...
],
...
},
In 1.20, the behaviorConfigs section was added. For behaviors that added to both sections, the properties may be specified in the behaviorConfigs section to avoid duplicating the properties in both the client and server section. Here is the above example using behaviorConfigs.
behaviorConfigs: {
"controlledphysics": {
"stepHeightByType": {
"deer-pampas-*": 2.1251,
"deer-pudu-*": 2.1251,
"deer-redbrocket-*": 2.1251,
"*": 3.1251
}
},
...
},
client: {
...
behaviors: [
...
{ code: "controlledphysics" },
...
],
...
},
server: {
...
behaviors: [
...
{ code: "controlledphysics" },
...
],
...
},
All Behaviors
Here is a table containing all the entity behaviors of the base game. Of course mods can, and are encouraged to add new behaviors.
Behavior Name | Explanation | Example entities | Properties | Side |
---|---|---|---|---|
aimingaccuracy | Adds aiming inaccuracy when sprinting, jumping, etc. |
|
Universal | |
breathe | The entity will need to breathe and therefore suffocate in other blocks (for example sand). |
|
Universal | |
collectitems | The entity collections items laying around on the ground. |
|
Server | |
controlledphysics | Add physics to the entity. |
|
stepHeight = 0.6 |
Universal |
despawn | The entity will despawn under given circumstances. |
|
minPlayerDistance |
Universal |
emotionstates | Adds emotion states with a given chance. As an example, it can be used to make an animal "hungry" (aggressive) and "saturated" (passive). |
|
states |
Server |
floatupwhenstuck | Float up the entity if it gets stuck in a block. |
|
onlyWhenDead = false |
Universal |
grow | The entity will grow and eventually turn into one of its adults. |
|
hoursToGrow = 96 |
Server |
health | Applies custom health to the entity. Means the entity can be hurt as well. |
|
currenthealth = 20 |
Server |
hunger | Adds saturation and hunger, the entity needs to eat in order to stay alive. |
|
currentsaturation = 1200 maxsaturation = 1200 saturationlossdelay = 60 * 24 currentfruitLevel = 0 currentvegetableLevel = 0 currentgrainLevel = 0 currentproteinLevel = 0 currentdairyLevel = 0 |
Server |
interpolateposition | Interpolates entity position and rotate. Smooths out the animations. It's a visual effect, therefore not available on server side. |
|
Client | |
multiply | A pack of wolves for example grows in size over time (new babies are born). When installed on the client side, it shows portions eaten info text. |
|
pregnancyDays = 3.0 |
Universal |
nametag | Adds a name tag to the entity which will be displayed above the entity. |
|
renderRange = 99 |
Universal |
passivephysics | Adds physics to the entity. |
|
waterDragFactor = 1 |
Universal |
placeblock | The entity will place one of the given block codes from time to time. |
|
minHourDelay = 8 * 24 |
Server |
playerphysics | Makes an entity controllable by a player. Because this inherits from controlledphysics, do not add both to an entity. |
|
stepHeight = 0.6 |
Universal |
repulseagents | Pushes other entities back. |
|
|
Universal |
taskai | Allows you to specify tasks. |
|
aitasks |
Server |
tiredness | The entity will get tired over time. When it is sufficiently tired, it may sleep in a bed. |
|
currenttiredness = 0 |
Universal |