Json block behaviors WrenchOrientable: Difference between revisions
(Created page with "== Purpose == Allows the wrench cycles through different variants of the block in its wrench group. Left clicking on the block with wrench will cause the block to get replaced with the next one in the wrench group. Right clicking will replace the block with the previous one in the wrench group. All block variants that enable the <code>WrenchOrientable</code> behavior with the same <code>baseCode</code> property are placed in that wrench group. The <code>baseCode</code>...") |
|||
Line 2: | Line 2: | ||
Allows the wrench cycles through different variants of the block in its wrench group. Left clicking on the block with wrench will cause the block to get replaced with the next one in the wrench group. Right clicking will replace the block with the previous one in the wrench group. | Allows the wrench cycles through different variants of the block in its wrench group. Left clicking on the block with wrench will cause the block to get replaced with the next one in the wrench group. Right clicking will replace the block with the previous one in the wrench group. | ||
All block variants that enable the <code>WrenchOrientable</code> behavior with the same <code>baseCode</code> property are placed in that wrench group. The <code>baseCode</code> is typically chosen as a prefix of the variant name for code style purposes, but any name could be chosen, as long as it does not match any other wrench groups. Typically all of the block variants in a wrench group are rotated versions of the same block, but it is possible to put different types of blocks in the same group, and the wrench would cycle between all of them. | The <code>baseCode</code> property is required. All block variants that enable the <code>WrenchOrientable</code> behavior with the same <code>baseCode</code> property are placed in that wrench group. The <code>baseCode</code> is typically chosen as a prefix of the variant name for code style purposes, but any name could be chosen, as long as it does not match any other wrench groups. Typically all of the block variants in a wrench group are rotated versions of the same block, but it is possible to put different types of blocks in the same group, and the wrench would cycle between all of them. | ||
The following example puts all variants of each wood type of placed logs in its own variant group. The <code>baseCode</code> is "log-placed-{wood}". For instance, the "log-placed-oak" wrench group contains "log-placed-oak-ud", "log-placed-oak-ns", and "log-placed-oak-we". Grown logs are not wrench rotatable, because the earlier "*-grown-*" clause overrides the subsequent "*" clause with the <code>WrenchOrientable</code> behavior. | The following example puts all variants of each wood type of placed logs in its own variant group. The <code>baseCode</code> is "log-placed-{wood}". For instance, the "log-placed-oak" wrench group contains "log-placed-oak-ud", "log-placed-oak-ns", and "log-placed-oak-we". Grown logs are not wrench rotatable, because the earlier "*-grown-*" clause overrides the subsequent "*" clause with the <code>WrenchOrientable</code> behavior. |
Revision as of 03:17, 11 October 2023
Purpose
Allows the wrench cycles through different variants of the block in its wrench group. Left clicking on the block with wrench will cause the block to get replaced with the next one in the wrench group. Right clicking will replace the block with the previous one in the wrench group.
The baseCode
property is required. All block variants that enable the WrenchOrientable
behavior with the same baseCode
property are placed in that wrench group. The baseCode
is typically chosen as a prefix of the variant name for code style purposes, but any name could be chosen, as long as it does not match any other wrench groups. Typically all of the block variants in a wrench group are rotated versions of the same block, but it is possible to put different types of blocks in the same group, and the wrench would cycle between all of them.
The following example puts all variants of each wood type of placed logs in its own variant group. The baseCode
is "log-placed-{wood}". For instance, the "log-placed-oak" wrench group contains "log-placed-oak-ud", "log-placed-oak-ns", and "log-placed-oak-we". Grown logs are not wrench rotatable, because the earlier "*-grown-*" clause overrides the subsequent "*" clause with the WrenchOrientable
behavior.
{
code: "log",
...
behaviorsByType: {
"*-grown-*": [...],
"*": [... { name: "WrenchOrientable", properties: { baseCode: "log-placed-{wood}" } }]
},
variantgroups: [
{ code: "type", states: ["grown", "placed"] },
{ code: "wood", states: ["aged"], loadFromProperties: "block/wood" },
{ code: "rotation", states: ["ud", "ns", "we"] },
],
...
}
Note that aside from using the WrenchOrientable
behavior, there is another way to enable the wrench interaction with blocks. If the block class implements IWrenchOrientable
, then the wrench will call IWrenchOrientable.Rotate
on the block. It would be a mistake to have a block use both the WrenchOrientable
behavior and have a block class that implements IWrenchOrientable
, but for such blocks WrenchOrientable
takes precedence.
Used by
- banner
- brickslabs
- brickstairs
- carvedlog
- chute
- clayshinglelabs
- clayshinglestairs
- clutter
- cobblestoneslab
- cobblestonestairs
- debarkedlog
- glassslab
- jonas
- log
- mudbrickslab
- planks
- plankslab
- plankstairs
- plaster
- polishedrockslab
- quartzpillar
- quartzslab
- quartzstairs
- stonebrickslab
- stonebrickstairs
- stonepathstairs
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 |