Event when entity looks at Player

Started by JennaF64 on

Topic category: Help with modding (Java Edition)

Last seen on 21:26, 2. Sep 2024
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Event when entity looks at Player

Hello, 

I'm currently making a mod that features a creature that causes an effect if it spots you.

The way I'm tackling this is via this procedure:
https://imgur.com/kVEXFF7
The only issue with this procedure is that as soon as I open the world, and the entity loads in, the game crashes. I assume this is because of the heavy performance that is required to run these code blocks.
 

The closest forum post is this one:
https://mcreator.net/forum/108222/help-how-check-if-there-block-between-entity-and-player

 

Last seen on 06:02, 13. Sep 2024
Joined Apr 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
it doesn't crash due to…
Mon, 08/26/2024 - 17:17

it doesn't crash due to performance, you need to check if an entity of type player exists in that square cube size first 

Last seen on 21:26, 2. Sep 2024
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ah, I see.  I added that and…
Mon, 08/26/2024 - 20:14

Ah, I see. 

I added that and it looks like it crashes the game when I (the player) gets near the area the entity is looking at.

There seems to be a lot of crashing when I use any of the raycast blocks but in this case I kind of have to use it.

Last seen on 06:02, 13. Sep 2024
Joined Apr 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
alright, I figured out why…
Mon, 08/26/2024 - 21:43

alright, I figured out why it was still crashing. this is the right procedure: https://imgur.com/7gla9sd