I am trying to make a command block command for server I am playing at, that would make any creeper near it not explode. As they still somehow spawn where they shouldnt and keep blowing up behind people when they use public chests. With the terrible and messy info on wiki I was able to come up with this:
/data modify entity @e[type=minecraft:creeper,distance=0..50,limit=1] ExplosionRadius set value 0
But it just keeps editing single nearest creeper, so I tried to make it ignore ones that already have it set to 0, but it seems to still only affect one creper repeatedly if try to do this this way:
/data modify entity @e[type=minecraft:creeper,nbt=!{ExplosionRadius:0},distance=0..50,limit=1] ExplosionRadius set value 0
So then I thought that I could just add a tag to it named like "noexplode" or something. but it seems to only allow you to edit one value with single command...
/data modify entity @e[type=minecraft:creeper,tag=!{noexplode},distance=0..50,limit=1]ExplosionRadius merge value 0 //and here I dont know how to make it also add a tag to it.