mojira.dev
MC-70754

testfor cannot test for ActiveEffects because Duration is ticking down

I tried to give a score to players with a specific status effect as well as testing for players with a specific status effect.

However, the commands I used don't ever find a player with the specified NBT Data. /testfor doesn't work as well.

Further testing showed it is the same with mobs.

The commands are:

/scoreboard players set @a canSwim {ActiveEffects:[{Id:17}]}
/testfor @a {ActiveEffects:[{Id:17}]}

Commands for testing purposes:

/scoreboard players set @a canSwim 1 {ActiveEffects:[{Id:17,Amplifier:0,Duration:595,Ambient:0,ShowParticles:1}]}
/testfor @a {ActiveEffects:[{Id:17,Amplifier:0,Duration:595,Ambient:0,ShowParticles:1}]}

EDIT
Since, as Aaron Rhodes said, it might be confusing to see a score name of canSwim and the hunger effect in one command:

I was trying to create a permanent world rule which only lets you swim or dive if you have the hunger effect on you. Otherwise it kills the player trying. It is a part of an ongoing series on YouTube.

EDIT2
Alright, I found a solution, I needed to use "17b" instead of "17". You need to specify the type of the tag. I am not sure if it is intended, however, it is not the bug I posted this issue about. Thank you!

Commands:

/scoreboard players set @a canSwim {ActiveEffects:[{Id:17b}]}
/testfor @a {ActiveEffects:[{Id:17b}]}

Comments 8

What are you trying to accomplish with these commands? A more detailed explanation would help. The score name of canSwim and the effect of hunger don't seem to go together, so its a little confusing.

Alright, sorry, Aaron. Here goes the explanation:

I was trying to create a permanent world rule which only lets you swim or dive if you have the hunger effect on you. Otherwise it kills the player trying. It is a part of an ongoing series on YouTube.

Now, it can be accomplished if you just track stats of eaten rotten flesh (or putterfish, problems begin with raw chicken) and give players this status effect just in case they didn't get it. However, that is not really what I want to accomplish, only a temporary solution.

The problem is probably Duration:595 in the testfor commands, the duration of the effect ticks down at the players after being applied.

Alright, I found a solution, I needed to use "17b" instead of "17". I am not sure if it is intended, however, it is not the bug I posted this issue about. Thank you!

Well ok. Didn't see that.

Rule of thumb: You always need to provide the data types in testfor commands.

Edit: Yes, this is intended.

Thanks for the help and sorry for bothering.

So just to be sure, the issue is resolved now?

Tomasz WIśniewski

(Unassigned)

Plausible

Minecraft 1.8

Retrieved