Help to make the mob knockback to a specific key.

Started by Hopzep on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help to make the mob knockback to a specific key.

I want to knockback a target entity that the player is looking at by pressing the "Z" key, but I can only knockback the "nearest entity". Help me please.

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use vectors: Vx, Vy, Vz. Add…
Wed, 07/09/2025 - 21:18

Use vectors: Vx, Vy, Vz.

Add "Repeat (EX: 100) times" block. Add the local variable "radius". Then add the block "For each entity as entity iterator at (X + Vx * radius, Y + Vy * radius, Z + Vz * radius) in square of 2". Inside add "Override motion vector of entityiterator to Vx, Vy, Vz" and "Break loop".

Finally increase "radius" by 1 each time.