Modding:Entity Behaviors

From Vintage Story Wiki

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
activitydriven
  • villager
Server
aimingaccuracy Adds aiming inaccuracy when sprinting, jumping, etc.
  • player
  • playerbot
Universal
antlergrowth
  • deer
  • animals with horns

beginGrowMonth
c1
c2
c3
growDurationMonths
grownDurationMonths
noItemDrop
overrideType
shedDurationMonths
variants

Universal
armorstandinventory
  • armorstand
Universal
bodytemperature
  • player
Universal
boss
  • eidolon-immobolized

musicTrack

Client
breathe The entity will need to breathe and therefore suffocate in other blocks (for example sand).
  • player - both sides
  • most animals - server only
Universal
collectitems The entity collections items laying around on the ground.
  • player
  • bot
  • racoon
Server
commandable
  • erel
  • locust-hacked
  • mechhelper
Universal
controlledphysics Add physics to an entity that can move on its own.
  • most entities

stepHeight = 0.6

Universal
conversable
  • libraryresonator
  • trader
  • villager

dialogue

Universal
deaddecay
  • animals

decayedBlock
hoursToDecay

Server
despawn The entity will despawn under given circumstances.
  • projectiles - server only
  • animals - both sides

afterDays
belowLightLevel
minPlayerDistance
minSeconds = 30

Universal
drunktyping
  • player
Client
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

Server
extraskinnable
  • player
  • playerbot
Universal
floatupwhenstuck Float up the entity if it gets stuck in a block.
  • item
  • most animals

onlyWhenDead = false
pushVelocityMul = 1

Universal
grow The entity will grow and eventually turn into one of its adults.
  • pig-wild-piglet
  • most baby animals

hoursToGrow = 96
adultEntityCodes = []

Server
harvestable
  • wolf
  • harvestable animals

drops
duration
fixedweight

Universal
health Applies custom health to the entity. Means the entity can be hurt as well.
  • bear
  • player
  • most entities

currenthealth = 20
maxhealth = 20
basemaxhealth = 20

Server
hidewatersurface
  • boat

hideWaterElement

Client
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
idleanimations
  • player
Universal
interpolateposition Interpolates entity position and rotate. Smooths out the animations. It's a visual effect, therefore not available on server side.
  • most entities
Client
milkable
  • goal
  • sheep-bighorn-female
Universal
mortallywoundable
  • elk-tamed

whenBelowHealth

Universal
mouthinventory
  • racoon

acceptStacks

Universal
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

eatAnyway
growthCapEntityCodes
growthCapQuantity
growthCapRange
pregnancyDays = 3.0
quantityPerDay
spawnEntityCode
requiresNearbyEntityCode
requiresNearbyEntityRange = 5
multiplyCooldownDaysMin = 6
multiplyCooldownDaysMax = 12
portionsEatenForMultiply = 3
spawnEntityCode
spawnEntityCodes
spawnQuantityMin = 1
spawnQuantityMax = 2
requiresFood = true

Universal
multiplybase
  • chicken-hen

multiplyCooldownDaysMax
multiplyCooldownDaysMin
portionsEatenForMultiply

Universal
nametag Adds a name tag to the entity which will be displayed above the entity.
  • player
  • playerbot
  • trader
  • villager

renderRange = 99
selectFromRandomName
showtagonlywhentargeted = false

Universal
openablecontainer
  • erel
  • mechhelper
Universal
passivephysics Adds physics an entity that cannot move on its own, but it still affected by things like wind and gravity.
  • item
  • thrownstone
  • most projectiles

waterDragFactor = 1
airDragFallingFactor = 1
groundDragFactor = 1
gravityFactor = 1

Universal
passivephysicsmultibox
  • boat
  • boat-construction
Universal
pettable
  • chicken
  • farm animals
  • fox
  • wolf

minGeneration

Server
placeblock The entity will place one of the given block codes from time to time.
  • hen - prior to 1.15 update

minHourDelay = 8 * 24
maxHourDelay = 15*24
blockCodes = []

Server
playerinventory
  • player
Universal
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
repulseagents Pushes other entities back.
  • most entities

movable = true

Universal
reviveondeath
  • eidolon-immobilized
  • trader
  • villager

maxHours
minHours

Server
rideable
  • elk-tamed
Universal
rideableaccessories
  • boat
  • elk-tamed
Universal
ropetieable
  • elk-tamed
  • farm animals
  • wolf

minGeneration

Universal
seatable
  • boat
Universal
selectionboxes
  • boat
  • boat-construction
  • elk-tamed
Universal
seraphinventory
  • armorstand-aged
  • playerbot
Universal
taskai Allows you to specify tasks.
  • most entities

aitasks

Server
tiredness The entity will get tired over time. When it is sufficiently tired, it may sleep in a bed.
  • player

currenttiredness = 0

Universal
villagerinventory
  • villager
Both


Content Modding
Basics Content Mods Developing a Content Mod Packaging & Release
Tutorials
Concepts Modding Concepts Modinfo Variants Domains Patching Remapping World Properties
Moddable Assets
Uncategorized
 

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 ItemEntityEntity BehaviorsBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsCollectible 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