I would like to create a mechanism (1.12 compatible and preferably forward compatible to 1.13) to trigger a function when an item is used or block is placed. For example, I would like to give items like the following 'magic beans':
/give @p minecraft:flower_pot 1 0 {display:{Name:"Magic Beans",Lore:["Creates Beanstalk"]}}
And then when the flower pot is placed by the player I would like a gamerule or advancement (not sure which to choose) to trigger a function at the spot where the block was placed or based on the location of the player that placed the block.
The function would do something like set blocks, fill spaces, grant status effects etc. The idea is that I want to learn how to marry up actions a player can do with custom created blocks or items to kick off functions - and my understanding is that using the scoreboard or advancements might be a good way to do this as an alternative to using command blocks.
I would appreciate a solution that shows what the separate text/json files would contain as well as the relative paths that they would be placed in. For the sake of examples I would plan on having /nsfunc/ and /nsadv/ namespaces in the save folder under functions and advancements respectively.
After some suggested that this is like other existing questions let me elaborate a little. What I am after is a very low maintenance solution, ideally without command blocks. I am trying to determine a simple way for a player to execute functions using specially created inventory so that the player can move around and trigger a function without much setup. For example, throwing a snowball or potion in combat that can trigger complex functions (such as fill the target area with ice blocks). Another example would be placing a block/hitting a block with a custom tool/ standing on a block wearing special armor in order to trigger a function. I don't mind game rules because they can be created and interacted with by the player. I would like to avoid command blocks because they generally require a little more setup by the player. I would like to make a system that can be used by a 6 year old and be easy to setup via a single function call. If a command block or two are truly necessary, I can live with that, but another thing I am aware of is potential performance problems - I would like to be able to extend this two dozens and dozens of function triggering tools, weapons, blocks, entities etc. and I don't want to bog down the PC with dozens of independently running rules. Ideally I would like a single test clock that can maintain a large list of potential item tags that are used to test if conditions are met to make these function calls.
For extra credit I would like to also see how to do something like this by throwing a custom (named) potion or snowball to trigger a function (via advancement or gamerule).
I am currently tinkering with creating a custom sign with an attached function. This satisfies the goal of having a portable way for users to trigger functions. The downsides of signs are 1) they require a second click after placement and, 2) what I would really like is to be able to make dynamic sorts of tools and weapons for combat. I am kind of trying to build a 'magic' arsenal, such as can transform blocks or mobs when used (creeper to bat via kill creeper then summon bat at location, or morph stone block to diamond block with swing of special pickaxe or thrown snowball).
Again simplicity is key. If command blocks, gamerules or achievements are used, I would like to 'compartmentalize them in a way that. I can call a single function once and have that function create all the command blocks, rules or achievements at once in order to get the system up and running for good in a lag conscious setup. My understanding is that in 1.13 I can make use of ticks to run the repeating elements and that there is more flexibility with selectors. For this problem I wouldn't mind replacing or destroying the pot after placement so that there is only ever one custom pot in the world.
Assistance is greatly appreciated.