Nearest Entity Procedures Detect players in Spectator Mode

Started by Mindthemoods on Mon, 11/14/2022 - 00:54

Topic category: Troubleshooting, bugs, and solutions

Last seen on 22:18, 30. Jan 2023
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Nearest Entity Procedures Detect players in Spectator Mode
Mon, 11/14/2022 - 00:54

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?

Last seen on 22:45, 7. Feb 2023
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Maybe check if the player is…
Mon, 11/14/2022 - 07:07

Maybe check if the player is in gamemode spectator?

Last seen on 18:37, 30. Nov 2022
Joined May 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I have quite a few…
Mon, 11/14/2022 - 18:38

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.