[FIXED] Trying to Launch the Player With setVelocity Code

Started by rmsandegs on

Topic category: Advanced modding

Last seen on 00:30, 24. Aug 2023
Joined May 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[FIXED] Trying to Launch the Player With setVelocity Code
Fri, 04/03/2020 - 16:54 (edited)

In my mod I have a pair of wings you can craft and put in your inventory. By pressing the 'C' key, you can "flap" with the wings and they send you into the air. The item and the keybind work fine, but it's the procedure of launching the player into the air that I'm having problems with.

I modified the procedure to use "addVelocity" to accomplish this. It worked in MCreator 1.9.0 but is mysteriously broken in 1.9.1. I've looked online for a very long time but haven't come to anything that's worked so far.

The strange part is that the rest of the modified procedure works perfectly. It plays an Ender Dragon wing flap sound and creates some flame particles. That all works. It's only the addVelocity part.

The problem line of code is this: 

entity.addVelocity(entity.getLookVec().x, 1.2 + (entity.motionY * -1), entity.getLookVec().z);

where "entity" is referring to the player and getLookVec is used to launch the player in the 'x' and 'z' direction they're looking in.

This is the only place I know to post stuff like this, but if you don't focus on custom code I entirely get it. Thank you for your time nonetheless.

Edited by rmsandegs on Fri, 04/03/2020 - 16:54
Last seen on 00:30, 24. Aug 2023
Joined May 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
For people curious, MCreator…
Fri, 04/03/2020 - 16:55

For people curious, MCreator has added "set entity motion" procedure blocks. But, if you must use code, use entity.addVelocity() instead.