Json block behaviors HorizontalUpDownOrientable: Difference between revisions

From Vintage Story Wiki
(Created page with "== Purpose == Used for: * angledgearbox Requires <code>abstract/verticalorientation</code> and <code>abstract/horizontalorientation</code>: <syntaxhighlight lang="json"> var...")
 
(→‎Purpose: Link to Modding:Block_Orientation)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Purpose ==
== Purpose ==
The [[Modding:Json_Block_Behaviors|behavior]] selects an [[Modding:Block_Orientation|orientation variant]] of a block when the block is placed. The orientation variant is selected based on the orientation of the player. The orientation type includes all 4 horizontal directions. In addition to having variants for all 4 horizontal directions with the block right side up, the orientation type includes an additional 4 horizontal directions with the blocks upside down. So the orientation type has a total of 8 states.


Used for:
When the block is broken, the "up" "north" variant is dropped.
* angledgearbox
 
Requires <code>abstract/verticalorientation</code> and <code>abstract/horizontalorientation</code>:
== Used by blocks ==
 
This behavior is not used by any of the vanilla blocks.
 
== Usage ==
 
The second to last variant group of the block must include the "up" and "down" states. The last variant group of the block must include the 4 cardinal directions. The variant groups must be the last 2 in the block, but the codes of the variant groups do not matter for this behavior.
 
The variant states can be specified directly via the <code>states</code> field, is cleaner to load them from the <code>abstract/verticalorientation</code> and <code>abstract/horizontalorientation</code> [[Json:block:worldvariantgroups|world properties]]:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
variantgroups: [
variantgroups: [
{ loadFromProperties: "abstract/verticalorientation" },
{ code:"v", loadFromProperties: "abstract/verticalorientation" }
{ loadFromProperties: "abstract/horizontalorientation" }
{ code:"side", loadFromProperties: "abstract/horizontalorientation" }
],
],
</syntaxhighlight>
</syntaxhighlight>
== Properties ==
none
{{Navbox/modding|Vintage Story}}

Latest revision as of 02:31, 16 October 2023

Purpose

The behavior selects an orientation variant of a block when the block is placed. The orientation variant is selected based on the orientation of the player. The orientation type includes all 4 horizontal directions. In addition to having variants for all 4 horizontal directions with the block right side up, the orientation type includes an additional 4 horizontal directions with the blocks upside down. So the orientation type has a total of 8 states.

When the block is broken, the "up" "north" variant is dropped.

Used by blocks

This behavior is not used by any of the vanilla blocks.

Usage

The second to last variant group of the block must include the "up" and "down" states. The last variant group of the block must include the 4 cardinal directions. The variant groups must be the last 2 in the block, but the codes of the variant groups do not matter for this behavior.

The variant states can be specified directly via the states field, is cleaner to load them from the abstract/verticalorientation and abstract/horizontalorientation world properties:

	variantgroups: [
		{ code:"v", loadFromProperties: "abstract/verticalorientation" }
		{ code:"side", loadFromProperties: "abstract/horizontalorientation" }
	],

Properties

none

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