0

My friends and I are making a PVP map and we're working on the summoner/mage class, which summons things that deal damage at the position of a projectile. For testing purposes, I'm making a snowball that summons lightning at its position. I have an objective called age that counts up every frame for every snowball, and the lightning will only be summoned after the snowball's age increases to a certain value, to stop the lightning from spawning on the player and damaging them (for testing purposes, that "certain value" is 20). I have an objective called numbers which simply stores values (this is where the aforementioned 20 is stored). Right now, I have execute as @e[type=minecraft:snowball] if score @s[type=minecraft:snowball] age > 20 numbers run summon minecraft:lightning_bolt but instead of summoning the lightning at the snowball, it summons it at the command block. How can I fix this?

2

as only changes the executor of the command (what @s is), not the position. To set the position of the command to the snowball, use at @s:

execute as @e[type=minecraft:snowball] at @s if score @s age > 20 numbers run summon minecraft:lightning_bolt

Also, you don't need [type=minecraft:snowball] in if score @s[type=minecraft:snowball] because @s will always be a snowball (you selected only snowballs in @e[type=minecraft:snowball]).

| improve this answer | |

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.