Block Transformers
A block transformer is a data-driven JSON file listing the rules that turn the block an item is used on into another one, like axes stripping logs, hoes tilling dirt, shovels flattening paths or honeycombs waxing copper. An item opts in through the block_transformer component, which points to the file by ID.
File Structure
The file is a list of 1 to 200 rules, tried in order until one gives a block state. Vanilla ships axe, hoe and shovel.
Creating a Block Transformer
Use blockTransformer on your DataPack and add rules with rule. Each rule takes a block state provider picking the new state, usually a ruleBasedStateProvider checking the clicked block, and an optional block setting its options. The function returns the ID of the file, ready to give to an item:
Generated data/<namespace>/block_transformer/strip_oak.json:
A file without any rule, or with more than 200, throws when the pack is generated. Inline rule lists on the item component aren't possible because the game only reads a block transformer from a file.
Rule Options
| Option | Type | Description |
|---|---|---|
consumeOnUse |
Boolean? |
Whether the item is consumed on use, for stackable items only. Defaults to true. |
disallowedFaces |
List<Direction>? |
The clicked faces the rule ignores, the next rule is tried instead. Defaults to none, so every face works. |
dropStrategy |
BlockTransformDropStrategy? |
CLICKED_FACE or FROM_MIDDLE, where loot drops. Defaults to FROM_MIDDLE. |
itemDamagePerUse |
Int? |
The durability lost per use, at least 0, for unstackable items only. Defaults to 0. |
loot |
LootTableArgument? |
The loot table dropped on success. Defaults to nothing. |
particle |
BlockTransformParticle? |
NONE, SCRAPE, WAX_OFF or WAX_ON, spawned on success. Defaults to NONE. |
sound |
SoundEventArgument? |
The sound played on success. Defaults to none. |
transformType |
BlockTransformType? |
SINGLE_BLOCK or COPPER_CHEST, which also transforms the other half of a double copper chest. Defaults to SINGLE_BLOCK. |
updateFromNeighbors |
Boolean? |
Whether the transformed block updates its shape from its neighbors. Defaults to true. |
See Also
- Components - The
blockTransformeritem component - Features - Block state providers picking the new block state
- Loot Tables - The
lootdropped by a rule
