1

I've seen this done before, and even though I am highly proficient in commands, it seems this is the only thing I can't quite figure out.

When I click on an empty armor stand while my hands are empty, I want it to execute a command on the clicked-on entity. For example, I click on an entity (armor stand, villager, etc.) and lightning is summoned at the entity, or it tags the nearest sheep with a test tag.

6
  • Does this answer your question? gaming.stackexchange.com/questions/228250/minecraft-item-right-left-click-detection Commented Jul 21, 2017 at 21:15
  • I'm afraid not. For the project I'm doing, the player can't be holding any items. I appreciate your help, though. Commented Jul 21, 2017 at 22:16
  • Can you make the held item invisible? Commented Jul 22, 2017 at 20:19
  • I don't think so. For my project, the player should be able to walk up to it and be able to play it instantly without needing to change his inventory. It's a lightsaber dueling game, and the lightsaber is moved based on your selected item slot. To make it swing, I'd like the player to right click on an invisible entity that will execute the armor stand to make it swing its saber. I have an alternative solution, but this is the preferred method. Thanks again for helping. Commented Jul 22, 2017 at 23:32
  • 1
    You can modify the inventory and just put the same item with different damage values (and based on that different item models) into all 9 hotbar slots. Also it sounds to me like you want to just detect hitting the entity. Couldn't you then just put an invisible zombie in the same location and detect when its health changes? Commented Jul 23, 2017 at 8:33

1 Answer 1

1

To check hitting on a specific spot, you can put a "deactivated" mob at that location. To least affect the environment and have the same size as a player/standard mob, I recommend a skeleton:

/summon skeleton ~ ~ ~ {NoAI:1,NoGravity:1,Silent:1,ActiveEffects:{Id:14,Amplifier:1,Duration:2147483647,ShowParticles:0}}

To also make it not collide with the player, you can assign it to the same team as the player and then do:

/scoreboard teams option <team name> collisionRule pushOtherTeams

But if you are already using teams otherwise in your map, that might conflict with it.

4
  • I have one more question. I know that to detect an entity taking damage, I must use HurtTimes. I'm not exactly sure how to use it, as I have never needed to use it before. This command didn't work: scoreboard players tag @e[type=villager,name=nazswinglet] add takeDamage {HurtTimes:0s} This should tag all the villagers that have not been hit, right? It doesn't work, anyway. Commented Jul 23, 2017 at 15:51
  • Never mind, problem solved! Thank you so much for your help. Commented Jul 23, 2017 at 16:31
  • I would just use Health, because the entity is only used for marking, you can do whatever you want with it. Commented Jul 23, 2017 at 20:30
  • @SpiceWeasel Did this answer your question? If yes, please mark it as accepted so that this question doesn't remain open. Commented Aug 10, 2017 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .