how do i make reversed knockback enchant

Started by Emperor_GG on

Topic category: Help with Minecraft modding (Java Edition)

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how do i make reversed knockback enchant

 a simple enchant that is the reverse of knockback (like pulls entities closer rather than pushing them away)

also this will be for a custom smp (if this is helpful)

Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could do this by…
Sat, 09/03/2022 - 03:31

You could do this by overriding the entity vectors to be towards the player plus whatever they are. It takes some math with sins and cosines to do this in the right directions however.

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
try to play with the vector…
Mon, 10/07/2024 - 18:34

try to play with the vector on the screen i show you

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you dont need pull back…
Tue, 10/08/2024 - 21:47

If you dont need pull back through the air, eg the enchantment wont really work on flying entities.

Then use attempt to make (entity) find path to (player). Then either increase the speed factor depending on the enchantment level. The problem with this is that the path to the player may be obstructed and the entity wil move independently from the players location rather than pulling them to their x y z.

It might work better if you leave the speed factor and use override vx vy vz instead. Eg override vx (x delta movement + 0.2) vy (y delta movement + 0.2) vz (z delta movement + 0.2) . That should work on flying entities and physically pull the entity to you. It may break a little in certain situations like with height variations and around corners.

However on flat land and in most cases both should work.