How to move entity away from other entity?

Started by Nintwendo on

Topic category: Help with modding (Java Edition)

Last seen on 17:15, 10. Jan 2024
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to move entity away from other entity?

I am trying to impliment a custom knockback system into my mod, and I want to be able to control how far an entity gets knocked back by certain items. (Some items have more knockback, some have less) I'm using this procedure that I found on another post whenever an entity is hit by the item to override knockback and make an entity move forward in the direction it is facing:

Code

Now, I want the entity to move backwards in the direction the entity that hit it (In most cases the player) is facing, basically I want them to be knocked back by the player, however, when I try changing the Event/target entity in the set local: yaw block to source entity, it disables the entire procedure. (I can tell because I also set the vy to 0 instead of what the image shows, and the entity is still being knocked up)

I could use the raytracing block to make the entity face the player and then move backwards, but I want the entity to retain it's facing direction and move away from the player regardless of the direction they are facing.

What am I doing wrong? How can I make this work?

Last seen on 23:12, 13. Aug 2023
Joined Nov 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
well why don't you just add…
Fri, 02/05/2021 - 23:11

well why don't you just add vanilla knockback to all of your items?

Last seen on 17:15, 10. Jan 2024
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Because I want some items to…
Tue, 02/16/2021 - 18:26

Because I want some items to have less knockback than normal, can I apply negative knockback or like 0.5 knockback?

Also, I don't want the enchantment glint on the items, but I want it to get an enchantment glint if the item is enchanted with something else, is that possible?

Last seen on 17:15, 10. Jan 2024
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Also, wouldn't that increase…
Tue, 02/16/2021 - 18:28

Also, wouldn't that increase the enchantment weight of the item, I mean, you wouldn't be able to put as many enchantments on it?

Last seen on 11:43, 29. Mar 2024
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Change speed to a negative…
Tue, 12/28/2021 - 06:00

Change speed to a negative value.