1

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.

0

/data modify entity @e[type=minecraft:creeper,nbt=!{ExplosionRadius:0},distance=0..50,limit=1] ExplosionRadius set value 0

This doesn't work because the ExplosionRadius tag is a byte, and you're testing for it as an integer. /data modify entity @e[type=minecraft:creeper,nbt=!{ExplosionRadius:0b},distance=0..50,limit=1] ExplosionRadius set value 0 would work.


Your third idea could be done with two commands: /data modify entity @e[type=minecraft:creeper,tag=!noexplode,distance=0..50,limit=1] ExplosionRadius set value 0 and then /tag add @e[type=creeper,distance=0..50] add noexplode configured to run after it using a chain command block or function.


However, this entire hack is unnecessary, since you can just apply the tag to all creepers in the area in one fell swoop with /execute as @e[type=minecraft:creeper,distance=0..50] run data modify entity @s ExplosionRadius set value 0, obviating the need to check which creepers already have been modified entirely.

| improve this answer | |
  • thanks! Damn I somehow completely missed that part. As for the area command, then it would just keep continuously editing every creeper. I might be wrong but I suspect this way if no new creeper is detected in are then it does nothing, but if I edited all of them it would keep editing them all and use more server resources than the first option. Unless I am mistaken. – markoatonc Jun 29 at 23:14

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.