How can I prevent custom entity from targeting the farthest entity and ignore entities behind blocks?(SOLVED)

Started by Classic- on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I prevent custom entity from targeting the farthest entity and ignore entities behind blocks?(SOLVED)
Tue, 04/01/2025 - 10:55 (edited)

I'm trying to make a system that will allow my entity to target Monster Entities withing a certain radius. Shown Here

https://imgur.com/a/5feGuf2

Does anyone know how to make it not check for entities behind blocks and not target the farthest entity and target the nearest?

Edited by Classic- on Tue, 04/01/2025 - 10:55
Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Making it not target the…
Mon, 03/31/2025 - 10:55

Making it not target the last entity it finds should be easily solved by breaking out of the loop when the first entity is found.

I didn't look at your procedure that closely so forgive me if you are already doing this.

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
OH MY GOD THANKS SO MUCH IT…
Mon, 03/31/2025 - 14:06

OH MY GOD THANKS SO MUCH IT WORKS!! I didn't know about the whole break out thing very well thanks for the help!

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
https://imgur.com/a…
Mon, 03/31/2025 - 14:21

https://imgur.com/a/ei7EFTh

For anyone else who comes across this this procedure works and also stops attacking when the Entity Iterator goes behind something. Yeah it will still look at it still if no other target is nearby but, it will lock onto something else if its the same Entity Iterator that isn't behind something after.

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is that line of sight block…
Mon, 03/31/2025 - 14:24

Is that line of sight block a plugin?

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
it probably is. I couldn't…
Tue, 04/01/2025 - 10:54

it probably is. I couldn't tell ya I had plugins in MCreator for months now I forgot what the default blocks are.