Right-click detection has been made in different ways across Minecraft history. The introduction of interaction entities simplified it a bit, but they cannot be used in every scenario. Thus, tricky ways to detect right-clicks are still needed nowadays. Since structured components were released, one of the easiest way to do it was adding a minecraft:food component to an item, with nutrition, saturation and eat_seconds set to 0, and creating a custom advancement to detect its use. This procedure is not intuitive, non-intended by the feature and it forces the creation of advancements, that can become hard to debug.
However, in the latest snapshot 24w34a, the new minecraft:consumable component has been introduced. This component contains a new field called on_consume_effects, that can execute certain events after consuming the item.
My suggestion is adding a new consume effect called run_command capable of running commands (including functions). This would further simplify right-click detection to a nearly-optimal point. Moreover, this change would not just serve as a right-click-detection tool, but it can also be useful in other mechanics, such as custom items that make something more than giving an effect.
The customization that this new item component provides, along with the freedom to execute anything without the need to rely on custom advancements would make this a great addition to the command community and simplify debugging in complex data packs.
Please sign in to leave a comment.
1 Comments