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.

  • Does this answer your question? gaming.stackexchange.com/questions/228250/minecraft-item-right-left-click-detection – Fabian Röling Jul 21 '17 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. – SpiceWeasel Jul 21 '17 at 22:16
  • Can you make the held item invisible? – Fabian Röling Jul 22 '17 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. – SpiceWeasel Jul 22 '17 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? – Fabian Röling Jul 23 '17 at 8:33
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.

  • 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. – SpiceWeasel Jul 23 '17 at 15:51
  • Never mind, problem solved! Thank you so much for your help. – SpiceWeasel Jul 23 '17 at 16:31
  • I would just use Health, because the entity is only used for marking, you can do whatever you want with it. – Fabian Röling Jul 23 '17 at 20:30
  • @SpiceWeasel Did this answer your question? If yes, please mark it as accepted so that this question doesn't remain open. – Fabian Röling Aug 10 '17 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.