taunting other mobs

Started by FlameVex2211 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
taunting other mobs

i want to add an effect that when you have it, the mobs will stop fighting other players and set their attack target on the person who has the effect. any ideas how to do this?

Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The only mobs that natively…
Wed, 06/22/2022 - 12:15

The only mobs that natively store their target in a readable way are zombie pigmen and shulker bullets. However, there is a very roundabout method to achieve this for all living entities. This involves the following steps:

1. When the player has the effect, check in the area on update tick for any relevant entities (for all enemies, you can use if subType == Mob) via entity iterator.
2. Once a mob is found, get the entity they are targetting for attack (block found in Entity data tab) and set both of them to the same team which has friendly fire off. This should be iterated for all entities within the mobs targetting distance, and should ignore the event player when assigning teams.
3. Every player except the event player should be on the same team as the attacking entity, which should force the entity to attack the event player as mob targetting abides by friendly fire.

Obvious side effects include the other players not being able to hurt eachother, and that constantly checking such a large volume for entities such as zombies, which have a targettiing distance of 40m, would cause a relatively considerate amount of lag. This is the first method I have found that does not require code and utilises only what is available in the procedure creator. If you need help with the team component of the method, more information is available here:
https://minecraft.fandom.com/wiki/Commands/team