TransWikia.com

Is there a command that detects if a player has an effect?

Arqade Asked on November 29, 2020

I am building a map and I need a command that detects when a player (preferably in a certain team) has an effect. The effect I will be detecting is STRENGTH 255. I already tried this command: /execute if entity @a[nbt={ActiveEffects:[{Id:5b, Amplifier: 255b}]}], and ran a comparator off of it, but it didn’t seem to work. I also set the command block to repeat and always active. All feedback is appreciated.

One Answer

Why Doesn’t it Work

Minecraft Java ActiveEffects tag is written as a byte, and values over 127 will wrap around to -127. This means that level 128 is actually -127. 255 is actually -1.

Solution

Try this:

/execute if entity @a[nbt={ActiveEffects:[{Id:5b, Amplifier: -1b}]}]

Answered by Penguin on November 29, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP