0

I was screwing around and attempting to make a mechanism where if a player shoots an entity with a special arrow (that gives a potion effect as a marker), and then activates another command block, it would kill all entities with that potion effect. After searching extensively, I couldn't find any nbt effect that I could use to kill entities with a potion effect, and there most certainly was not any other argument after @e[, so is there any nbt effect to target it, or any other way that I overlooked?

I found an old answer suggesting scoreboard functions, but it seems to be outdated and have the same issue (commands not being able to discriminate/select entities based on active effects, as far as I can find).

1

The NBT tag you're looking for is ActiveEffects. For example, if you shoot a mob with a spectral arrow, it gets this NBT tag:

ActiveEffects:[{Id:24b,Duration:200,Amplifier:0b,Ambient:0b,ShowParticles:1b,ShowIcon:1b}]

So you can target every mob with the glowing effect like this:

@e[nbt={ActiveEffects:[{Id:24b}]}]

Unlike when setting NBT, you have to be exact when reading NBT, so you need the b.

The number is the numerical effect ID (archive).

  • I couldn't find it after like 2 hours yesterday, thank you so much! – iruleoverkittens Nov 24 '18 at 19:30
  • If it helped you, you can indicate that using the checkmark icon. It means something like "question is solved by this". – Fabian Röling Nov 25 '18 at 21:16

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.