Topic category: Troubleshooting, bugs, and solutions
A minor issue, but one that's proved a little frustrating: Procedures that detect entities do not differentiate between normal entities and players in spectator mode.
Essentially, I've been working on some trap blocks, and I've noticed that players in spectator mode will also trigger the traps. The blocks are set to detect living entities, but this apparently includes spectators. I can add a procedure to check that the nearest entity is not a player in spectator mode; but this still causes problems if there is both a living entity and a spectator nearby. (If I force the trap to only enable if the nearest entity is not a spectator, then a spectator could theoretically disable traps for a living player.
One solution that comes to mind is using an entity iterator to check all entities in range to see if there are spectators; but again, I can't think of a particularly elegant way to check that the trap has been triggered by a normal or spectating entity.
...In short, it would be nice if there was a way to differentiate between players and spectators, or at least to not have spectator-mode players included in the living entities section. At the moment I'm not too worried about this, but I'm sure there's some scenarios where it could be a bigger issue. (Minigames, or something.) Any ideas?
Maybe check if the player is in gamemode spectator?
I have quite a few procedures that should only work in certain modes. As VuFlub said, I just check to see if the entities gamemode is creative and spectator = false.
if event target gamemode is creative = false
and event target gamemode is spectator = false
do something cool
I think it can apply to any entity just fine.