[SOLVED, sorta] How do I detect if player is looking at my custom entity's head?

Started by akisephila on Wed, 06/23/2021 - 09:07

Topic category: Help with modding (Java Edition)

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
[SOLVED, sorta] How do I detect if player is looking at my custom entity's head?
Wed, 06/30/2021 - 01:15 (edited)

I understand that this can be done with the raytracing blocks but not only do the raytracing blocks seem nigh impossible to use (I can't even grab the XYZ of where the player is looking, because the "Look [X/Y/Z] position of [Event/Target Entity]" is a number block and can't be used with logic "AND" blocks), there are also zero tutorials that help me in the slightest, and all other forum topics I have checked on this matter have been useless.
Please help.

Edited by akisephila on Wed, 06/30/2021 - 01:15
You will need to raytrace…
Wed, 06/23/2021 - 11:34

You will need to raytrace look position and then check for entities in near range of this position

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How do I do that? There aren…
Wed, 06/23/2021 - 23:29

How do I do that? There aren't any tutorials.

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Bump
Thu, 06/24/2021 - 07:28

Bump

I suggest you check our…
Thu, 06/24/2021 - 16:45

I suggest you check our tutorials collection playlist on our YouTube channel which contains many examples and tutorials that can help you get started with MCreator: https://www.youtube.com/playlist?list=PLAeL-oIFIEngE6jRgFYeFMfuj8WQsO3Ei

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Klemen, you have been of…
Sun, 06/27/2021 - 02:11

Klemen, you have been of very little help, and evidently did not pay attention. I already said that there aren't any tutorials for what I am looking for help with.

Last seen on 13:47, 23. Jul 2021
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
i've been attempting to do…
Sun, 06/27/2021 - 03:03

i've been attempting to do this too. tried using a dynamic raytracing procedure i came up with where the distance increases while there's still no entity found, until it either finds an entity and then saves its name or reaches max distance and returns nothing at all, and it kinda works... but it still needs some polishing which I'll be completing very soon, then I'll share it. in the meantime, i can say that familiarizing yourself with how things, or parts of things, work by themselves and how they work with others, is essential to figuring things like these out. so for example, since "look x/y/z position w/ raytrace distance [n]" procedures return a number value, you can find whatever logic condition/check that takes in numbers for its parameters, e.g. "does entity exist at x y z", which i used, and put it in the x/y/z values of the logic condition as arguments. it'll then return either true or false depending on the check, and only then can you use it alongside "AND" block i believe

Last seen on 13:47, 23. Jul 2021
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
P.S. it requires a…
Sun, 06/27/2021 - 03:07

P.S. it requires a programmer's mindset to fully realize how do stuff like these... otherwise, you might not be able to get anywhere far as to achieve what you've been looking for

Last seen on 13:47, 23. Jul 2021
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
alright, here it is (as a…
Sun, 06/27/2021 - 08:44

alright, here it is (as a procedure template):

https://www.mediafire.com/file/1p11xvo5s8mgm9n/entity-raytrace-search.ptpl/file

if you have any questions, put em here or message me on Discord. or i can make a full tutorial in case the comments i put aren't enough

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Thank you so much for the…
Sun, 06/27/2021 - 11:02

Thank you so much for the help

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
@Sajevius So I'm using your…
Mon, 06/28/2021 - 05:23

@Sajevius
So I'm using your procedure in a player tick update, and it DOES detect my entity, but it doesn't do the action defined in the "if getlocal:entity_found" loop, which despawns the entity being looked at and spawns the hostile variant in its place. A little help?
Part 1 of the procedure

Part 2 of the procedure

Last seen on 13:47, 23. Jul 2021
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
don't do "is event/target…
Mon, 06/28/2021 - 05:48

don't do "is event/target entity subtype of [entity]", that won't work on the detected entity; that only works on the mob executing that procedure (in that case, the player). that's why it doesn't work. maybe do

"IF NOT get nearest entity at xrd | yrd | zrd in sqr cube 1 of type LivingEntity = (null) AND is get nearest entity at xrd | yrd | zrd in sqr cube 1 of type [entity 1] subtype of [entity 1] DO despawn get nearest entity at xrd | yrd | zrd in sqr cube 1 of type [entity 1]; spawn at xrd | yrd | zrd entity [entity 2]" instead

(for quick reference, i represented variable "raytrace_distance" with "rd", so take note of that)

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
thanks again, ill see if…
Mon, 06/28/2021 - 06:18

thanks again, ill see if this works!

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Turns out it doesn't work…
Mon, 06/28/2021 - 06:42

Turns out it doesn't work. Well, not entirely.
It despawns the entity looked at, and then decides to spawn around 20 instances of the hostile variant.
It also always happens regardless of whether the location looked at is the head or not (despite the fact I set the raytracing distance for the y coordinate to be itself + 2.25 blocks?

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
(No subject)
Mon, 06/28/2021 - 06:43

It would be funny if it weren't terrifying and laggy