How do I determine which hopper the user clicked in Minecraft with command blocks?

How do I determine which hopper the user clicked in Minecraft with command blocks? - White Metal High-rise Viewing Deck Building

I'm using Minecraft 1.10, if it helps. I'm making a mini-game where the player needs to rotate hoppers in order to direct items to the correct place (I'm summoning particles under the hoppers to indicate where items currently are). While deciding what the interface should be for the player controls, I realized that I can set the Lock tag on a hopper to prevent the UI from showing up when right-clicked, but it would still increase the stat.hopperInspected scoreboard stat when the player right-clicks it. Perfect! Just right-click a hopper to rotate it...except that there are going to be several (or many) hoppers next to each other, in a chain in fact. So once I know the player has right-click a hopper from the scoreboard, what's the best way to detect which hopper was clicked?

I already have a marker armor stand in each of the hoppers, for the particle indicators, if that helps. I just can't think of a good way. The best I've thought of is "force the player to stand directly under the hopper they're clicking", but that's not easy to enforce and would be problematic if they don't do it. (I guess I could /tp them to force them to look directly upwards, but that's also pretty terrible UI, I think...)

So what's the best way to do this?



Best Answer

Do you really need to click on hoppers? It would be much easiers to make player interact with invisible entities.
For example, you could have some gear in player's hotbar, that would be equipeed on armor stands as he right-clicks it.
Or you could use other entities like villagers for that. You could even make armor stand wear some gear already, but make it invisible via res. pack.




Pictures about "How do I determine which hopper the user clicked in Minecraft with command blocks?"

How do I determine which hopper the user clicked in Minecraft with command blocks? - Black and white side view full body sporty swimmer in swimming suit and goggles standing on block in track start position preparing to dive in outside pool
How do I determine which hopper the user clicked in Minecraft with command blocks? - Flexible young women performing yoga exercise in park
How do I determine which hopper the user clicked in Minecraft with command blocks? - Full body barefoot sportswoman in sportswear doing yoga arm exercise on sport mat during training on lawn in park adhering to healthy lifestyle while looking down



How do you know which way a hopper is facing in Minecraft?

Usage
  • A hopper has an "output" tube at its bottom that can face down or sideways and provides a visual indication of which block the hopper is set up to drop its items into, if that block has an inventory. ...
  • To open the hopper GUI, use the Use Item/Place Block control.




  • Right Click Detection in Vanilla Minecraft [1.16 Command Blocks]




    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Pixabay, Heart Rules, Gustavo Fring, Gustavo Fring