Make an item to lure mobs to you?

Started by schizoidfromhell on

Topic category: Help with modding (Java Edition)

Last seen on 20:34, 11. Sep 2023
Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Make an item to lure mobs to you?

I want to make an item that, on use, lures mobs within a certain radius, i.e. 10 blocks, to you. i have no clue where to so much as start.

Last seen on 18:01, 13. Jun 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The only reliable way I've…
Wed, 09/27/2023 - 15:35

The only reliable way I've found to micromanage entity pathfinding is with attack targets; you can override an entity's attack target to an entity, and make invisible entities with specific despawn conditions to set pathfinding to a specific location, or to reset an entity's hostility. In your case, you could make a procedure that, while holding the item, sets the attack targets of the desired entity type within a 10 block radius to the thing holding it. If the entities aren't hostile/neutral, that's probably fine, but if they are and you don't want them to attack the player, you could then create an invisible/hitboxless entity that despawns quickly, and set their attack target to this so they stop following the player. (You'd probably have to do this anyways to reset their pathfinding once the item is no longer in the player's hand.)