I’m trying to create a KitPvP with power-ups and I want it so that when someone with the archer kit throws an egg, it gives the person speed and strength. If there’s an add-on for it, please tell me.
2 Answers
It should be possible to do it with a command like this one:
/execute @e[type=egg] ~ ~ ~ effect @a[r=2,tag=archer] speed 10 3 true
This will give any player with the tag archer
who is within a radius of 2 blocks of an egg the effect speed
for 10 seconds on level 3, while not showing any particles (remove the true
if you want players to see the particles).
This will work for any archer throwing an egg, but it will also give other archers who are close to an egg the same effct.
You need to put the command into an active, repeating command block for it to work.
You can chain a command block with this command to give the second effects:
/execute @e[type=egg] ~ ~ ~ effect @a[r=2,tag=archer] strength 10 3 true
And a third command block with this command to remove eggs after they were thrown, to reduce how many players may get the effect (as flying eggs also gives the effects, so throwing an egg at an archer would give both archers the effects).
/kill @e[type=egg]
There is no way for a command block to know who exactly threw the egg in minecraft pocket edition, so after setting this all up EVERY archer within a small radius of the one throwing the egg will get the effects.
This is what it may look like if you set up all 3 command blocks:
-
You can tag a person as an archer with
/tag <player(s)> add archer
. If you want them to use a different tag you would have to remove the tag again withtag <player(s)> remove archer
– user232393Commented Jun 8, 2019 at 16:31 -
If you have a different system to know what kit someone is using, then you will have to modify the commands to fit your situation– user232393Commented Jun 8, 2019 at 16:32
I don't know what you mean by "when someone with an archer", but for this I'm assuming it's when a player is near someone with a bow.
Step 1: create an objective that tracks players who throw eggs.
/scoreboard objectives add egg minecraft.used:minecraft.egg
Step 2: run this command in a repeating command block.
/execute as @a[scores={egg=1}] if entity @a[distance=..4,nbt={Inventory:[{id:"minecraft:bow"}]}] run effect give @s speed
This targets all players who had thrown an egg and is within a 4 block radius of someone with a bow and gives the egg thrower speed.
Step 3: repeat step two with any additional effects, then run this last command in a chain command block.
/scoreboard players reset @a egg
Does that help?
EDIT: just noticed you said this is for pocket edition. This may not work after all.
-
-
In that case you can remove the part from "if" to right before "run", and edit the first string to make it to your liking. Commented Dec 10, 2018 at 0:29
-
Note nothing here will work as this is for the wrong edition of the game– PenguinCommented May 12, 2021 at 22:57