Event when entity looks at Player

Started by JennaF64 on

Topic category: Help with Minecraft modding (Java Edition)

Active 4 months ago
Joined Aug 2019
Points:
693

User statistics:

  • Modifications: 1
  • Forum topics: 5
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 6
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

 

Active 1 day ago
Joined Apr 2024
Points:
405

User statistics:

  • Modifications: 8
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 470
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 

Active 4 months ago
Joined Aug 2019
Points:
693

User statistics:

  • Modifications: 1
  • Forum topics: 5
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 6
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.

Active 1 day ago
Joined Apr 2024
Points:
405

User statistics:

  • Modifications: 8
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 470
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 

Active 4 months ago
Joined Aug 2019
Points:
693

User statistics:

  • Modifications: 1
  • Forum topics: 5
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 6
Sorry for the late response,…
Thu, 03/13/2025 - 07:34

Sorry for the late response, but thank you!

Active 1 day ago
Joined Apr 2024
Points:
405

User statistics:

  • Modifications: 8
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 470
You're welcome 
Thu, 03/13/2025 - 09:45

You're welcome