Custom items with right click detection - AmthystXx/Geode GitHub Wiki
Using geode, you can make items that detect a right click and run a function.
Example recipe:
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "minecraft:barrier"
}
],
"result": {
"id": "[Item]",
"components": {
"minecraft:food": {
"nutrition": 0,
"saturation": 0,
"can_always_eat": true,
"eat_seconds": 999999999
},
"minecraft:custom_data": {
"geode":"right_click",
"right_click_id":"[Path (namespace:path/function) to function that should run when the player right clicks]"
}
}
}
}
The function that runs while the player is holding right click will run every tick. If you want it to run slower than every tick, you need to write the logic yourself in the function.