Force Push

Started by Tucky143 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Force Push

I was trying to create force push keybind procedure but it wouldn't work. Can someone tell me what I would need to do? I want it to where if there is an entity in the direction your facing when the key is pressed, it will push that entity in the direction you are facing. Same, but opposite for force push.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There's a couple ways to do…
Sun, 04/07/2024 - 17:44

There's a couple ways to do this. The tricky part is mostly just choosing which entity to target.

The easiest method would be to use an entity iterator bracket to target all entities within a certain radius. (Code that targets the 'entity iterator' will be run on every entity in the radius.) You would want to check that the entity iterator does not equal the event/target entity, (otherwise the force push will also push you), and then use the 'attempt to override motion vector' function to set the x/y/z velocity of the entity iterator to the x/y/z look angle vectors of the event/target entity. This will cause all nearby entities to immedieately lose all velocity, and then move at a constant rate in the direction the player is looking while within the provided radius. (You can then multiply the look angle vectors to increase the strength of the push.) If you add the look angle vectors to the entity iterator's current x/y/z velocities instead of just overriding them, the force push will gradually override the existing motion of the nearby entities.

To target a specific entity, you would still need to use an entity iterator, but would also probably need to check if the entity iterator falls within the player's field of view. (That is, depending on the direction the player's looking, you would want to check if the entity iterator's position indicates it's in front of the event/target entity.) 

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you give me the code or…
Mon, 04/08/2024 - 23:43

Can you give me the code or image of the procedure for it?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Something like this, for the…
Tue, 04/09/2024 - 17:04

Something like this, for the simplest method:

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i love forums because people…
Tue, 06/11/2024 - 17:29

i love forums because people have your same problems.

Do you know if there is anyway to add more power to the push?

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You might be able to if you…
Tue, 06/11/2024 - 20:36

You might be able to if you multiply the angle look vector by 2.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yep, to add more power, (or…
Tue, 06/11/2024 - 20:59

Yep, to add more power, (or decrease the power), you just multiply the look angle vectors by a whole number, or a decimal. This works because look-angle vectors are always unit values. (They range from -1 to 1), and thus scale correctly.

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
sweet thanks for the help
Tue, 06/11/2024 - 21:18

sweet thanks for the help