Modding:Entity Behaviors

From Vintage Story Wiki
Revision as of 01:00, 6 October 2024 by Bluelightning32 (talk | contribs) (add using section)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.

	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" },
            ...
		],
        ...
	},