entity attack condition doesnt work

Started by a23709g3 on

Topic category: Help with modding (Java Edition)

Last seen on 08:57, 17. Jul 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
entity attack condition doesnt work

living entity attack condition doesnt work for me

i used all methods to make it, didnt worked in any.

Last seen on 18:36, 16. Jul 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Could you be a little more…
Thu, 10/19/2023 - 19:45

Could you be a little more specific about what isn't working? What methods have you tried, and what happened?

Last seen on 08:57, 17. Jul 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i wanted to make entity dont…
Sat, 10/21/2023 - 09:00

i wanted to make entity dont attack me if i wear specific armor.

i used all methods that i know in procedure to make it but none of them worked

Last seen on 18:36, 16. Jul 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The problem you're likely…
Sat, 10/21/2023 - 19:11

The problem you're likely having is that there isn't a built-in method to disable attack targets. You should be able to easily set the attack target of an entity to something else, but actually deaggravating it is more difficult. 

One workaround you could try is creating an invisible, immovable, unkillable entity with extremely high health. In your armors update tick, have it run an entity iterator in a large radius, targeting entities of the type you want to deaggravate. For each entity in the iterator, check if its attack target equals the event/target entity, (the player), and, if it does, spawn the invisible entity.

In the invisible entity's update tick, have it check for a nearby entity of the correct type, and, if it finds one, set that entity's attack target to itself. Then, despawn the invisible entity. This will effectively reset an entity's attack target, and as long as you use an entity iterator, it will do this for all of that entity type in a radius. It's not an ideal solution, but I've been able to get it working in the past.