Json block behaviors OmniRotatable
Purpose
The OmniRotatable
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. Note that WrenchOrientable behavior is similar, but it allows the variant to be changed after the block is placed with the wrench tool.
Used by blocks
- brickslabs
- clayshinglelabs
- cobblestoneslab
- glassslab
- mudbrickslab
- plankslab
- polishedrockslab
- quartzslab
- stonebrickslab
- trapdoor
Usage
There are several meaningful ways to define a group of orientation variants for a block. Each orientation type has different variant code requirements and different properties for the OmniRotatable behavior. Where possible, the examples below use world properties to assist in defining the variant states, but this is optional; the states may be directly listed instead.
Orientation type | Required variant codes | Example block | Example variant definition | Required behavior properties |
---|---|---|---|---|
All faces |
|
slab |
{
code:"rot",
loadFromPropertiesCombine: ["abstract/horizontalorientation", "abstract/verticalorientation"]
}
|
{ name: "OmniRotatable", properties: {rotateSides: "true"} } |
Verticals |
|
none |
{
code:"rot",
loadFromProperties: "abstract/verticalorientation"
}
|
{ name: "OmniRotatable", properties: {rotateV: "true"} } |
Horizontals |
|
none |
{
code:"rot",
loadFromProperties: "abstract/horizontalorientation"
}
|
{ name: "OmniRotatable", properties: {rotateH: "true"} } |
Horizontal Vertical |
|
none |
{
code:"rot",
loadFromProperties: "abstract/horizontalorientation"
},
{
code:"v",
loadFromProperties: "abstract/verticalorientation"
}
|
{ name: "OmniRotatable", properties: {rotateH: "true", rotateV: "true"} } |
2 Axis |
|
trapdoor |
{
code:"rot",
loadFromProperties: "abstract/horizontalorientation"
},
{
code:"v", states: ["left", "right"],
loadFromProperties: "abstract/verticalorientation"
}
|
{ name: "OmniRotatable", properties: {rotateH: "true", rotateV: "true", rotateV4: "true"} } |
Additionally, the behavior adds a placement mode to items. The behavior shows the placement mode when the item is hovered over in the inventory or hotbar. The placement modes are auto, horizontal, and vertical. Auto is the default. The horizontal and vertical modes only work correctly for the all faces type.
The behavior changes the placement mode when it detects that the block was created through crafting, and the first item in the recipe was an orientable block. So to allow changing the placement mode, add a 1x1 recipe that takes the block as input and produces it as output. The placement mode changes in the following cycle: auto to horizontal, horizontal to vertical, and vertical to auto.
Properties
rotateSides
: (boolean)- Enables the all faces type.
rotateH
: (boolean)- Enables orienting along the 4 cardinal directions.
rotateV
: (boolean)- Enables orienting up or down.
rotateV4
: (boolean)- This can only be used if
rotateV
is also enabled. It extends therotateV
mode to also use the "left" and "right" values for the vertical variant code. facing
: (string, default "player")- Tells the block what it should orient to. Typically "block" is used, since the player almost always is building against another block.
dropChance
: (float, default 1)- Values less than 1 reduce the chances of the block getting dropped when it is broken. Values 1 and above do not affect the drop rate.
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 | Item • Entity • Entity Behaviors • Block • Block Behaviors • Block Classes • Block Entities • Block Entity Behaviors • Collectible Behaviors • World properties |
Workflows & Infrastructure | Modding Efficiency Tips • Mod-engine compatibility • Mod Extensibility • VS Engine |
Additional Resources | Community Resources • Modding API Updates • Programming Languages • List of server commands • List of client commands • Client startup parameters • Server startup parameters Example Mods • API Docs • GitHub Repository |