This is how it could work:
/give @p minecraft:stick{events:{onUse:{mcfunction: "my_datapack:my_use_mcfunction", preventDefault: 1b}, onPunch:{mcfunction: "my_datapack:my_punch_mcfunction", preventDefault: 0b}}}
On an event like "use", (ie when the player right-clicks while holding the item), the game will first run the mcfunction specified. If the preventDefault tag is set, then the default behavior of the item (for example, throwing a fishing rod), is cancelled. The mcfunction is executed as the player and at the position that the player was looking at when they triggered the event.
This could also be applied to mobs too, where an event could be triggered when a mob is, for exampled, right-clicked or punched.
Please sign in to leave a comment.
2 Comments