[SOLVED] Pushing Away All Nearby Mobs

Started by Alec Cature on

Topic category: Help with modding (Java Edition)

Last seen on 23:55, 29. May 2024
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[SOLVED] Pushing Away All Nearby Mobs
Sat, 03/09/2024 - 21:56 (edited)

Hey all, I am making an ability that makes it so when a key bind is pressed, all mobs nearby (in like a 3 block radius) get blown back away from the player depending on where they are relative to the player's position (for example, if mobs are fully surrounding the player they will all get blown back away in a circle formation). I have the key bind made, I just can't figure out how to make the procedure to push mobs away correctly.

I've tried the 'explode at' block but when setting it to a higher explosion power to do more knockback, it ends up doing way more damage than I would like and most of the time just kills the mobs instead. I would like the use the 'override motion vector' block if possible as I feel like it has the best control when fine-tuning exactly how strong the push is.

Edited by Alec Cature on Sat, 03/09/2024 - 21:56
Last seen on 23:55, 29. May 2024
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Figured this out with a…
Sat, 03/09/2024 - 21:55

Figured this out with a slightly janky method, here is the code for anyone who may be interested in doing the same thing.



This is done by forcing all the nearby mobs to look at you, and then launches them in the opposite direction they are looking, and while this does work, I wouldn't mind still accepting a solution that doesn't involve snapping a mobs neck to look at you to if someone knows how.