Turn Block ON-OFF
You can turn on and off blocks on interact.
First create your block template. This is the base block that will be used to create the on and off blocks.
In this example I use built-in Minecraft models to avoid creating new models just for this example.
info:
namespace: test
items:
test_change_state_block_interact_template:
name: Test Change State Block Interact
template: true
resource:
generate: false
model_path: minecraft:block/diamond_block
material: PAPER
specific_properties:
block:
placed_model:
type: REAL_NOTE
cancel_drop: false
Now create the off block. This block has an event listener on interaction that replaces itself with the on block (that will be created next).
test_change_state_block_interact:
variant_of: test_change_state_block_interact_template
events:
placed_block:
interact:
replace_block:
from: test_change_state_block_interact
to: test_change_state_block_interact_on
decrement_durability: 0

Now create the on block. This block has an event listener on interaction that replaces itself with the off block (that we created before).
As you can see I specified the light_level: 15
property, to turn the light on.
test_change_state_block_interact_on:
variant_of: test_change_state_block_interact_template
specific_properties:
block:
placed_model:
type: REAL_NOTE
cancel_drop: false
light_level: 15
events:
placed_block:
interact:
replace_block:
from: test_change_state_block_interact_on
to: test_change_state_block_interact
decrement_durability: 0

Last updated
Was this helpful?