2

I am trying to make a custom item called a "Medigun" in Minecraft. Simply put, when you hold a skull with the name "Medigun", it activates a /execute command. I am trying to make it so that when you hold it, it gives an effect of Regeneration III to every entity around it within 4 blocks. So far, I have the command

/execute @a ~ ~ ~ /effect @e[r=4] minecraft:regeneration 10 2

set up, but when I hold it, all players on the server get Regeneration III. How can I make it so that only players near me will get this effect?

2

Use tags to target only players who are holding the gun.

Repeat block:

/scoreboard players tag @a remove HoldingGun

Chain blocks, in order:

/scoreboard players tag @a add HoldingGun {SelectedItem:{display:{Name:"Medigun"}}}

/execute @a[tag=HoldingGun] ~ ~ ~ /effect @e[r=4] minecraft:regeneration 10 2

Of course, I'm just assuming the Medigun item has a display name of Medigun; if it has other special tags, you should change those in the first command accordingly. (And I highly recommend including the item id inside the SelectedItem tag as well, so that people can't just rename other items to Medigun and get the effect.)

-2

I made a map, download and check the code.

http://www.mediafire.com/download/aj6hj05zy9z63bm/Medigun.zip

This command works for one player at a time.

  • 2
    Hi Akos! That's great that you have a link to an example, but would you be able to paste the answer here as well, along with a short description as to how you made it work? What if someone downloaded the map didn't know where to look? :( – NBN-Alex Aug 17 '16 at 0:18

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.