How to program game responses, e.g. If you use bone meal on grass in Minecraft, then plants grow, how do you program something like that?
You bumble in a loop and wait for keys to be pressed. If, as in your example, right-click is pressed, then what is looked at and what is in the hand is evaluated again in order to then trigger the corresponding action in the program.