[TUTORIAL] How to Create a Vertical Movement Controller for Rideable Entities

Started by Sajevius on

Topic category: User side tutorials

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] How to Create a Vertical Movement Controller for Rideable Entities
Wed, 02/10/2021 - 22:46 (edited)

As someone who loves experimenting with MCreator's procedures, I bring you guys a workaround for allowing your entities to move vertically, without writing any code whatsoever! Just in case you can't find any code help or are not good at coding and have been looking for help on this matter, you can follow this tutorial. This works well with flying mobs as far as I've tested, so here goes!


PREREQUISITES

  • MCreator 2020.5, Forge 1.15.2 generator (or at least that's the version I made this on)
  • a rideable flying entity
  • an adequate understanding of NBT tags & procedure systems 

STEPS

1. Creating Key Bindings

Make 2 key bindings. One will be for your mob's upward movement, the other will be for its downward movement. In my case, "spacebar" for flying up, and "R" for flying down, as I'm comfortable with those.

Spacebar - upward movement

For allowing your entity to move upward

 

R - downward movement

For allowing your entity to move downward

 

These key bindings, when used, will alter an NBT variable that will be utilized for our entity's vertical movement, which we'll talk about soon. 

And here's how it starts. Hold on tight!

 

2. Upward Movement Key Bind - Procedures

Go to the upward movement key bind (spacebar) and use its two triggers.

 

In its "On key pressed" trigger, make a procedure that checks if the entity being ridden by the player is a (sub)type of your flying entity. If true, then set an NBT tag with name "VerticalMovement" type "number" of the ridden entity to value of "1", which value would signify that the entity is currently flying up.

It should look like this:

flying up

 

In its "On key released" trigger, make a procedure that also checks for the entity being ridden by the player. However, this procedure should set its aforementioned NBT tag "VerticalMovement" to "0" once you let go of spacebar.

hovering

 

3. Downward Movement Key Bind - Procedures

Go to the downward movement key bind (R), and just like in the spacebar key bind, use its two triggers.

 

In its "On key pressed" trigger, make a procedure that... once again, checks the ridden entity's (sub)type. This time, set the "VerticalMovement" NBT tag to "-1", which would signify that the entity is flying down.

flying down

 

And in its "On key released" trigger, make a procedure that looks exactly like what we did on the upward movement key bind "on key released" trigger (refer to the 4th image in this forum topic once more). Alternatively, you could save a few seconds of life and just reuse the "On key released" procedure of the spacebar key bind, since they're intended to do the exact same thing (setting "VerticalMovement" to 0.)

 

4. Entity Living Tick - Procedures

Here comes the best part: actually letting the entity fly up and down in response to the keybinds the player presses! This procedure is where the magic happens. And I promise, this is the last thing we'll do.

Go to your entity, go to its Triggers tab, and add an "On entity tick update" procedure.

entity tick update trigger

 

Edit the procedure, and do this:

on entity tick update

Basically, this procedure first gets the flying entity's "VerticalMovement" NBT tag. If the tag's value equals "1", then set the entity's Y velocity to 0.3; this will make the entity slowly fly upward. Else, if "VerticalMovement" equals "-1", set the Y velocity to -0.3, which makes the entity slowly fly downward.

 

5. Testing

Now save it, build the workspace and run the client, test it in-game and see if it works!


That's pretty much it. I hope this tutorial helped you, and happy modding! :D

 

P.S. if there's anything wrong, if you have suggestions, or need further help, let me know in the replies!

Edited by Sajevius on Wed, 02/10/2021 - 22:46
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for this tutorial…
Sat, 08/28/2021 - 10:09

Thanks for this tutorial Sajevius! it helped me allot

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I cant find the Set Movement…
Fri, 03/25/2022 - 00:08

I cant find the

Set

Movement Vector to vx:

Vy:

Vz:

was it renamed?

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yeah, it was renamed to …
Fri, 03/25/2022 - 08:18

yeah, it was renamed to "attempt to override motion vector of [entity] to vx: [x] vy: [y] vz: [z]"

Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok so for those who can't…
Sat, 12/03/2022 - 21:37

Ok so for those who can't find the right blocks: 

"data number NBT tag"      is now     "custom number NBT tag"

and

"set movement vector to..."     is now     "attempt to override motion vector of..."

Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oops didn't realize you…
Sat, 12/03/2022 - 21:38

Oops didn't realize you already mentioned some of that.

Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Bro thx so much I wanted to…
Thu, 12/22/2022 - 10:04

Bro thx so much I wanted to make Dambo mod

Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
where is the updated version
Thu, 03/30/2023 - 21:18

where is the updated version

Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i am trying to make a flying…
Sat, 04/15/2023 - 16:56

i am trying to make a flying entity but the up/down movement have some kind of drift do you know how to fix this?

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here is what I figured out…
Fri, 04/28/2023 - 23:47

layout for the updated entity tick procedure

Here is what I figured out using this tutorial.

Seems the only real update is a slight change to the part that controls overriding the movement vectors.

Joined Jan 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
tried to do it but whenever…
Thu, 05/04/2023 - 09:50

tried to do it but whenever i try to go up or down the entity just mover back and down or back and up suuuuper fast! takes me hundreds of blocks away o.o and i followed the tutorial to the letter 

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sajevius, i have an issue,…
Thu, 06/15/2023 - 23:21

Sajevius, i have an issue, so i did what you mentioned and it looks like this

https://ibb.co/pQhP2Dp

but when i ride the entity it does not move when i press the space key

and i know that most of it is working becuase when i did this

https://ibb.co/Tgxt6ty

i got the chat message displaying when i held space while riding my entity

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
nvm it works now i just…
Sat, 06/17/2023 - 12:31

nvm it works now i just enabled ai for the entity

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It only works when im riding…
Mon, 07/10/2023 - 11:57

It only works when im riding the entity, for some reason Minecraft crashes when i press the keybind while im not riding the entity.