I'm trying to testfor
if a fake player called MobHunger on a scoreboard objectives that is Stats. I tried this:
/testfor MobHunger[score_Stats_min=1,Team=Mob_Hunger]
but it doesn't work... any ideas?
If you are on the 1.9 snapshots, you can use the scoreboard to test nonexistent players:
/scoreboard players test (playername) (objectivename) (min) (max)
(I assume you are on 1.8+) Since you cannot test for a player that isn't in game, Try using an armorstand.
First, Summon an armorstand with the nbt tags NoGravity, Marker, and CustomName. (Ex. /summon ArmorStand ~ ~ ~ {NoGravity:1b,Marker:1b,CustomName:MobHunger}
To set it a scoreboard, you can use an entity selector in place of the player. This would work: scoreboard players set @e[type=ArmorStand,name=MobHunger] stats 1
You can also use an entity selector in the testfor command, it's just a bit different syntax. /testfor @e[type=ArmorStand,name=MobHunger,score_stats_min=1]
Also, just a tip: try transitioning over to the execute command rather than testfor, as with testfor you need an comparator and a different command that needs to target the entity (unless you need that comparator for lag or other purposes). With execute, you can do a command in the same command if it finds the armorstand with a score of 1 in stats. Ex. execute @e[type=ArmorStand,name=MobHunger,score_stats_min=1] ~ ~ ~ setblock ~ ~ ~ stone
is much more efficient than using a comparator.
scoreboard operations
, but testfor
and it's more useful cousin execute
(or any targeted command for that matter) need to resolve an existing entity to function, and fake players aren't entities.