Can somebody help me with entity directions?

Started by RaolTheBest on

Topic category: Advanced modding

Last seen on 17:49, 25. Mar 2021
Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can somebody help me with entity directions?
Tue, 07/21/2020 - 17:41 (edited)

I wanted to create some daggers that deal additional damage when used behind the target (similarly to the mod Backstab for 1.12.2).

I thought that if the player is attacking the target from behind, it means they have a similar direction. So I made a condition that checks if the absolute (if it's negative, turn it to positive) difference between the direction of the player and the target is littler than a set value (I chose 50).

However, after a few playtesting, I remembered that the direction is relative to south and can vary from 0 to 360. I tried working around that, but I later realised that the direction system is somehow weird (west, for example, sometimes it is considered as +270 and sometimes as - 90...).

After placing a circle of armorstands all facing a different direction and using a procedure block that sends a text showing both the player's and the target's direction, I managed to almost fix it by turning anything negative into positive and to have a condition that checks if a direction is higher than 180 and, if it is, to set it to 360 minus that value.

It works almost always, the only issue now is it doesn't really distinguish west from east so it triggers the "backstab" effect even if the player and the target are facing each other, if the directions are east and west.

So, after spending a whole afternoon trying to find a solution I began to hate armorstands... Does anybody have an idea? XD

(If you need it I can post the procedure here)

Edited by RaolTheBest on Tue, 07/21/2020 - 17:41
Last seen on 17:49, 25. Mar 2021
Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Anyone? :(
Wed, 07/22/2020 - 14:04

Anyone? :(

Last seen on 17:49, 25. Mar 2021
Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nevermind, thanks to 2020.4…
Tue, 08/25/2020 - 20:33

Nevermind, thanks to 2020.4 I managed to fix the issue by  using the compare directions block (F for that day spent on overly complex procedures that didn't work).

If you want to check the Combat module it was just released

Last seen on 00:42, 10. Oct 2023
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh I never noticed this…
Tue, 08/25/2020 - 21:39

Oh I never noticed this topic. Otherwise I would have tried finding a solution.

Last seen on 17:49, 25. Mar 2021
Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Don't worry, 2020.4 removed…
Wed, 08/26/2020 - 07:20

Don't worry, 2020.4 removed the whole need to make that huge procedure XD

Last seen on 00:42, 10. Oct 2023
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well it would have taken me…
Sun, 08/30/2020 - 01:00

Well it would have taken me ages anyway since I don't know how most procedures work.

Last seen on 18:59, 28. Jan 2023
Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Since you figured it how can…
Fri, 01/06/2023 - 23:52

Since you figured it how can you show the procedure i dont quite understand it