Pull Mob Towards Player w/ Weapon

Started by Beezwhat on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Pull Mob Towards Player w/ Weapon

Hello! Currently I am coding a custom scythe and want it to be that whenever you hit a mob, it will pull it towards you. I've looked on the forums and couldn't find an answer to this so plz send help!!!

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can try to use the…
Sat, 01/10/2026 - 16:59

You can try to use the Attempt to override motion vector to vx vy vz block. I've never used it so I'm not sure how does it work, but it should basicly apply motion to entities. It will very likely use a lot of math tho.

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yeah I've tried using it. It…
Sat, 01/10/2026 - 17:01

Yeah I've tried using it. It pretty much moves the mob in the direction of x, y, or z. But not to a specific block.

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well can't you just put the…
Sat, 01/10/2026 - 17:03

Well can't you just put the coordinates of the block there?

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
No, that's not how it works…
Sat, 01/10/2026 - 18:24

No, that's not how it works. You need to calculate the direction by doing semi-complex subtraction-based math. I've done it before, but I forgot the specifics. I think you basically subtract one X position from another, and that gives you the x direction from one to the other (you need to be careful what direction you're going in), then repeat for Y and Z. And you might also want to do some calculation of total distance, multiplication, and division on the directions to have it carry the ratios of the X, Y, and Z directions, but set them to a static absolute total so the power of the weapon isn't based on how close you are to your target.

Again, this is vaguely what I remember, but I may have forgotten parts of it, and I don't remember the specific numbers or things like do you do target position - source position, or source position - target position to go inwards.

Hopefully this helps a little.

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok so if I understand what…
Sat, 01/10/2026 - 18:33

Ok so if I understand what you're saying, I should have it be like this:

x1, y1, z1 are the Target's cords
x2, y2, z2 are the User's cords

attempt to override motion vector of [Target Entity] to vx: [x2 - x1] vy: [y2 - y1] vz: [z2 - z1]
 

Is this correct?

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, I think something like…
Sat, 01/10/2026 - 19:09

Yes, I think something like that. Although you might need to experiment with the potency some (like multiplying [x2 - x1] by 2 or 0.3 or something, repeated for y and z as well). And there's a chance that it would be [x1 - x2], but I can't remember that part exactly.

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok great thanks for the…
Sat, 01/10/2026 - 19:10

Ok great thanks for the advice!!!

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You're welcome. I hope you…
Sat, 01/10/2026 - 19:18

You're welcome. I hope you're able to get it working.