So this is a new item component that essentially serves as right click detection, however it is more complex than just a simple right click check. This is an example of how it would work:
/give @s minecraft:stick[interact_event={on_press:{function:"namespace:function"}}]
So when the stick is right clicked, it will run the function. Now, look at this:
/give @s minecraft:bow[interact_event={on_release:{function:"minecraft:summon_arrow"}}]
This event will trigger when the input is held down and released. There is also more to this component:
/give @s minecraft:trident[interact_event={on_release:{function:"minecraft:summon_trident",seconds:3..}]
This will make the item run the function only when the item was released after the input was being held down for 3 or more seconds. Here is an example where we create an item with multiple interact events:
/give @s minecraft:iron_ingot[interact_event={on_press:{seconds:1,function:"namespace:function1"},on_release:{seconds:3..,function:"namespace:function2"}}]
This creates an iron ingot, which if held down for exactly 1 second (without releasing) it will run function1. Then, when they release the input, if it was held down for 3 or more seconds, it will run function2.
This can really help datapack makers create polished custom items without having to rely on tricks and workarounds using advancements and consumables.
Please sign in to leave a comment.
0 Comments