Block Behaviours
Block behaviours can be customized to add unique properties to blocks. All behaviours are optional, and some can be applied to both, blocks and decorations.
Blocks also work with most item-behaviours to give the blocks' item special features.
Some block behaviours provide blockstate properties you will have to provide models for, like axis, repeater, crop, directional, etc.
Example of a blockResource entry for the repeater behaviour (can be found as relay block in the example datapack):
Click to expand
{
"blockResource": {
"models": {
"facing=up,powered=false": "minecraft:custom/block/arcanery/relay/relay_up_off",
"facing=down,powered=false": "minecraft:custom/block/arcanery/relay/relay_down_off",
"facing=north,powered=false": "minecraft:custom/block/arcanery/relay/relay_north_off",
"facing=south,powered=false": "minecraft:custom/block/arcanery/relay/relay_south_off",
"facing=east,powered=false": "minecraft:custom/block/arcanery/relay/relay_east_off",
"facing=west,powered=false": "minecraft:custom/block/arcanery/relay/relay_west_off",
"facing=up,powered=true": "minecraft:custom/block/arcanery/relay/relay_up_on",
"facing=down,powered=true": "minecraft:custom/block/arcanery/relay/relay_down_on",
"facing=north,powered=true": "minecraft:custom/block/arcanery/relay/relay_north_on",
"facing=south,powered=true": "minecraft:custom/block/arcanery/relay/relay_south_on",
"facing=east,powered=true": "minecraft:custom/block/arcanery/relay/relay_east_on",
"facing=west,powered=true": "minecraft:custom/block/arcanery/relay/relay_west_on"
}
}
}
You can also provide rotations for the block model like so:
{
"blockResource": {
"models": {
"lit=false,facing=north": { "model": "minecraft:block/furnace", "y": 0 },
"lit=false,facing=south": { "model": "minecraft:block/furnace", "y": 180 },
"lit=false,facing=east": { "model": "minecraft:block/furnace", "y": 90 },
"lit=false,facing=west": { "model": "minecraft:block/furnace", "y": 270 },
"lit=true,facing=north": { "model": "minecraft:block/furnace_on", "y": 0 },
"lit=true,facing=south": { "model": "minecraft:block/furnace_on", "y": 180 },
"lit=true,facing=east": { "model": "minecraft:block/furnace_on", "y": 90 },
"lit=true,facing=west": { "model": "minecraft:block/furnace_on", "y": 270 }
}
}
}
Example of a block with behaviours set:
Click to expand
{
"id": "mynamespace:myblock",
"blockResource": {
"models": {
"...": "mynamespace:custom/block/myblock",
"...": "..."
}
},
"blockModelType": "full_block",
"properties": {
"destroyTime": 0,
"blockBase": "minecraft:stone"
},
"behaviour": {
"powersource": {
"value": 15
},
"repeater": {
"delay": 1,
"loss": 1
},
"fuel": {
"value": 10
},
"food": {
"hunger": 2,
"saturation": 1.0,
"canAlwaysEat": true,
"fastfood": true
},
"cosmetic": {
"slot": "chest",
"model": "mynamespace:custom/models/clown_backpack_animated",
"autoplay": "idle",
"scale": [1.5, 1.5, 1.5],
"translation": [0.0, 0.5, 0.0]
},
"strippable": {
"replacement": "minecraft:stone"
}
}
}
This creates a block + item that can be worn and when worn shows an animated blockbench model on the player. The item is also a food and can be used as fuel source in furnaces.
The block acts as a redstone powersource of level 15 and a repeater/relay and is strippable (turns to stone when stripped with an axe or an item with the stripper item behaviour)
While possible, you probably don't want to combine powersource with repeater for actual blocks/items for obvious reasons.
Behaviours
axis behaviour
Gives the block an axis property/block-state similar to wooden logs/pillars and handles placement.
count behaviour
Gives the block a count property/block-state.
Works similar to turtle eggs or candles, allows you to place "multiple blocks/items" into one block.
facing behaviour
Gives the block a facing property/block-state similar to wooden logs/pillars and handles placement.
horizontal_facing behaviour
Gives the block a facing property/block-state similar to furnaces and handles placement.
Does not support up and down facing directions.
crop behaviour
Makes the block behave like a crop, bonemeable, growing, minimum light requirement, etc. Also gives a growth bonus similar to vanilla crops, which check for farmland blocks in a 3x3 area centered below the crop block. The bonus block and radius can be configured.
You probably want to use this behaviour together with the can_survive behaviour.
If you want your custom crop block to not turn farmland into dirt without moisture, like vanilla crops do, add your block to the block tag maintains_farmland.
In order for the farmland to not turn into dirt when placing the crop on top of it, make sure the solid property is set to false
For bee pollination, use the block tag bee_growables.
You can make farmer villagers able to plant the seeds using the item tag villager_plantable_seeds. Villagers will only work on crops that are on top of farmland blocks (vanilla limitation).
maxAge: maximum age steps of this block (from 0 to maxAge-1). Defaults to 4.minLightLevel: Minimum light level this crop needs to survive. Defaults to 8.bonusRadius: Radius to check for bonus blocks for. Defaults to 1.bonusBlock: Bonus block to check for. More bonus blocks means faster growth. Defaults tominecraft:farmland.villagerInteraction: Allows farmer villagers to break and plant the custom crop. Defaults totrue.beeInteraction: Allows bees to pollinate the crop to increase its age. Defaults totrue.
sapling behaviour
Makes your block behave like vanilla saplings, growing based on random ticks and bonemealable.
All identifiers for the configured_placements are optional, they will only get used when configured.
You add your own configured placement for trees using vanilla datapack mechanics.
stage: 0 to 1. You can provide a single model to use for both states, usedefaultas key in that case.
tree: Identifier for a configured_placement (add via datapack or use vanilla ones)minLightLevel: Defaults to9secondaryChance: Chance between 0 and 1 forsecondaryMegaTreeorsecondaryFlowersplacement to be used. Defaults to0randomTickGrowthChance: Defaults to0.15bonemealGrowthChance: Defaults to0.45megaTree: Identifier for a configured_placement. Will get used for 2x2 sapling placementssecondaryMegaTree: Identifier for a configured_placement. Alternative tomegaTreebased onsecondaryChancetree: Identifier for a configured_placement. Normal tree without flowersecondaryTree: Identifier for a configured_placement. Alternative totreebased onsecondaryChanceflowers: Identifier for a configured_placement. Used when there is a flower neaby.secondaryFlowers: Identifier for a configured_placement. Alternative toflowersbased onsecondaryChance
can_survive behaviour
Checks for the block below with one of the configured block tags or blocks list. The block will break off, similar to flowers or crops, when the block below them is not supported.
The behaviour will automatically check for and apply any facing or axis block-state properties.
Useful for bushes/plants/crops/flowers and more
blocks: List of blocks this block can survive on.- Example:
blocks: ["minecraft:stone", "minecraft:sand"]
- Example:
tags: List of block-tags this block can survive on.- Example:
tags: ["minecraft:dirt", "minecraft:sculk_replaceable"]
- Example:
powersource behaviour
Defines the block as a redstone power source.
repeater behaviour
Defines the block as a redstone repeater with configurable delay and loss.
delay: Delay in ticks. Defaults to 0loss: Power loss during transfer. Defaults to 0
powered: true, falsefacing: north, east, south, west, up, down
powerlevel behaviour
Supplies a powerlevel blockstate and changes to it depending on the input redstone signal.
strippable behaviour
Defines the block as strippable, replacing it with another block when interacted with an axe.
replacement: The identifier of the block to replace the current block with. Example:minecraft:stonelootTable: Identifier for a loot table to use when the block is stripped. Example:minecraft:bell
slab behaviour
Defines the block as slab, top, bottom, double, with placements, waterloggable.
trapdoor behaviour
Trapdoor like block.
facing: north, south, east, west, up, downhalf: top, bottomopen: true, falsewaterlogged: true, false
canOpenByWindCharge: Whether the trapdoor can be opened by a wind charge. Defaults totruecanOpenByHand: Whether the trapdoor can be opened by hand. Defaults totrueopenSound: Open sound. Defaults to wooden trapdoor open sound.closeSound= Close sound. Defaults to wooden trapdoor close sound.
door behaviour
Door-like "block" that is 2 blocks high. Comes with all door block state properties (hinge, open, powered, etc.)
facing: north, south, east, west, up, downhalf: lower, upperopen: true, falsehinge: left, right
canOpenByWindCharge: Whether the door can be opened by a wind charge. Defaults totruecanOpenByHand: Whether the door can be opened by hand. Defaults totrueopenSound: Open sound. Defaults to wooden door open sound.closeSound= Close sound. Defaults to wooden door close sound.
simple_waterloggable behaviour
Simple waterloggable block.
waterlogged: true, false
drop_xp behaviour
Makes the block drop xp when being mined without the silk-touch enchantment.
{
"behaviour": {
"drop_xp": {
"min": {
"age=0": 0,
"age=1": 0,
"age=2": 4
},
"max": {
"age=0": 0,
"age=1": 0,
"age=2": 6
}
}
}
}
block_interact_execute behaviour
Executes a command on block interaction from console, as player (@s).
consumes: Flag whether the block should be broken after running the command(s). Defaults tofalsedropBlock: Flag whether the block should drop items when broken. Defaults tofalsecommand: The command string to execute. Empty by defaultcommands: List of commands to execute. Empty by defaultatBlock: false/true flag whether the command should be run at the blocks' positionsound: Optional sound effect to play during execution. Empty by default
block_attack_execute behaviour
Executes a command when the block is "attacked", from console, as player (@s).
consumes: Flag whether the block should be broken after running the command(s). Defaults tofalsedropBlock: Flag whether the block should drop items when broken. Defaults tofalsecommand: The command string to execute. Empty by defaultcommands: List of commands to execute. Empty by defaultatBlock: false/true flag whether the command should be run at the blocks' positionsound: Optional sound effect to play during execution. Empty by default
oxidizable behaviour
Defines the block as oxidizing block, similar to the vanilla copper blocks, randomly replacing it with another block when it "ages". Can be reverted/scraped by axes and resets with lightning bolts like vanilla copper blocks.
replacement: The identifier of the block to replace the current block with (e.g., "minecraft:stone").weatherState: The current weathering state of this block. Can beunaffected,exposed,weathered,oxidized. Defaults tounaffected. AweatherStateofoxidizedwill not oxidize any further.
budding behaviour
With this behaviour the blocks grows other blocks, similar to budding amethyst blocks. The sides, blocks and chance can be configured.
If the blocks in grows have directional/facing block state properties, they direction of the side the block is growing from will be set.
chance: Chance of the block to grow another block or move a block to the next growth stage in percent, from 0 to 100. Defaults to 20sides: List of sides blocks can grow out. Can benorth,south,east,west,upordown. Defaults to all directionsgrows: List of id's of blocks for the growth stages. Example:["minecraft:chain", "minecraft:end_rod"]
grass_spread behaviour
Allows the block to spread like mycelium or grass blocks do, based on random ticks.
decayBlockState: Chance of the block to grow another block or move a block to the next growth stage in percent, from 0 to 100. Defaults to 20propagatesToBlocks: List of List of blocks this block can spread to. Defaults to["minecraft:dirt"]propagatesToBlockTags: List of block tags this block can spread to. Empty by default
falling_block behaviour
Makes the block a gravity affected/falling block like sand or anvils.
delayAfterPlace: Delay in ticks before the block falls. Defaults to 2heavy: To cause anvil-like damage. Defaults to falsedamagePerDistance: Accumulated damage per block fallenmaxDamage: Maximum damage a falling block can dealdisableDrops: Prevent the block from being placed when it fallssilent: Flag whether sounds are played when the block falls or breakslandSound: Sound played when the block landsbreakSound: Sound played when the block breakscanBeDamaged: Flag whether the block should be placed as the block indamagedBlockdamagedBlock: New block to use when the falling block 'breaks'. Will copy applicable block state propertiesbaseBreakChance: Chance for the block to break into the block indamagedBlockon its ownbreakChancePerDistance: Chance increase per block fallen for the block to break into the block indamagedBlock
{
"falling_block": {
"delayAfterPlace": 2, // delay in ticks before the block falls
"heavy": true, // to cause anvil-like damage
"damagePerDistance": 2.0, // accumulated damage per block fallen
"maxDamage": 40, // maximum damage
"disableDrops": false, // prevent the block from being placed
"silent": false, // no sounds
"landSound": "minecraft:block.anvil.land",
"breakSound": "minecraft:block.anvil.destroy",
"canBeDamaged": true, // flag whether the block should be placed as the block in "damagedBlock"
"damagedBlock": "minecraft:diamond_block", // new block to use, will copy applicable block state property
"baseBreakChance": 0.05, // chance for the block to "break" to the block in "damagedBlock"
"breakChancePerDistance": 0.05 // chance increase per block fallen
}
}
tnt behaviour
With this behaviour the block can be lit with flint and steel or redstone to spawn a TNT entity with the blockstate of this block.
- unstable: Flag whether the block explodes when a player tries to break it. Defaults to
false - explosionPower: Explosion power. Defaults to
4.0 - fuseTime: Fuse time (delay until the tnt entity explodes). Defaults to
80 - primeSound: Sound to play when the block is primed. Defaults to
minecraft:entity.tnt.primed
Block behaviours with block entity
The following block-behaviours require a block entity. They can not be pushed, so make sure the pushReaction in your block properties is set to destroy, block or ignore.
furnace behaviour
Furnace behaviour with menu.
Combine this with the horizontal_facing behaviour for a vanilla-like furnace block!
Checkout the example datapack to see how to configure it.
hopper behaviour
Hopper behaviour with menu.
facing: north, south, east, west, downenabled: true, false
filterItems: List of items and/or item tags. Defaults is empty. Example:["minecraft:diamond", "#minecraft:dirt"]would allow for diamonds and all items with theminecraft:dirtitem-tag.pickupItemEntities: Flag whether item entities should be picked up. Defaults totruetakeFromContainer: Flag whether items from the container above should be taken. Defaults totruecooldownTimeCooldown time before transfering a new item. Defaults to8
flammable behaviour
Makes the block flammable.
leaf_decay behaviour
Makes the block decay like leaf blocks.
Adds distance and persistent block state properties to the block.