Make The Monster Despawn When Looked At

Started by JustMonitor on

Topic category: Help with Minecraft modding (Java Edition)

Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Make The Monster Despawn When Looked At

Hello, I want to make my entity spawn lightning and despawn when the player looks at him even if he is 200 blocks away, using procedures, I hope yall can help.

Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can recommend you…
Mon, 04/01/2024 - 14:56

I can recommend you something that i've tried and worked for me, but is a bit poor, you need to insert into entity tick this command that would be executed from the entity (but first you will need to make a synched data for the entity(In my case i will call it "Test")):

execute as @p at @s anchored eyes facing entity @e[type=mod_id:entity_id,limit=1,sort=nearest] eyes anchored feet positioned ^ ^ ^1 rotated as @s positioned ^ ^ ^-1 if entity @s[distance=..0.1] run data merge entity @e[type=mod_id:entity_id,limit=1,sort=nearest] {DataTest:1b}

(i recommend you to play with the distance)

This would make the Test synched Data of the entity became true, now inside the tick update you must put a procedure that makes this:

if  entity... Test = true{
   (Here you put your execution)
   (here you must set the Test to false to avoid he loop)
}

Hope this helps you, and sorry if bad english ;)

Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for the help but can…
Thu, 05/16/2024 - 18:58

Thanks for the help but can you explain it using blocks not code ?