Started by
Emperor_GG
on
Topic category: Help with Minecraft modding (Java Edition)
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)
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.
here you go https://ibb.co/sJh6W1n
try to play with the vector on the screen i show you
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.