How can i detect closest entity that is not itself?

Started by XenraO on

Topic category: Help with modding (Java Edition)

Last seen on 08:40, 9. Nov 2023
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can i detect closest entity that is not itself?
Tue, 09/12/2023 - 18:39 (edited)

(firstly I'm sorry for my bad english you guys can asl if don't understand the problem.) 

I'm working on a enchantment that deals damage like chain. 

When bow has this enchanment, when i hitted entity it will give a custom potion effect named "shocked". I want to spread this potion effect to nearest entity.
A chain that spreading to those around it one by one. And since I want it to proceed in a "chain" manner, I do not want to use the "For each entity in square cube" procedure, which covers all the targets around. And at the same time, "nearest entity (living entity)" only marks itself. 

How can i detect nearest entity without the entity i attacked with arrow? also I don't know coding so I need to do this in "procedure"

If you guys know plugin will can solve this problem, i can use.

Edited by XenraO on Tue, 09/12/2023 - 18:39
Last seen on 21:37, 17. Feb 2024
Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try doing "For each entity…
Fri, 09/15/2023 - 15:19

Try doing "For each entity in square cube", and detect the distance yourself, but exclude the main entity?

Last seen on 05:40, 21. Jan 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you can always just remove 1…
Sat, 09/16/2023 - 17:22

you can always just remove 1 from the entity count so as to not count itself.

OR If you're working with other functions w/ entity detection just, check if the entity count >1 to start executing

Last seen on 05:40, 21. Jan 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could also execute…
Sat, 09/16/2023 - 17:23

You could also execute whatever you wanted to execute on all the entities and then remove those stuffs from the main entity(itself)

Last seen on 05:40, 21. Jan 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
pardon my language, it's…
Sat, 09/16/2023 - 17:23

pardon my language, it's pretty late and I'm half-asleep