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

Started by Sajevius on

Topic category: User side tutorials

Last seen on 10:51, 1. Jul 2024
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
Last seen on 10:51, 1. Jul 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh no. bad news, guys - I'm…
Mon, 02/08/2021 - 12:54

oh no. bad news, guys - I'm dumb :P 

let me explain. I just realized that I got some things wrong in this tutorial. like, since I basically created a global variable, that means just one player pressing "spacebar" or "R" will alter that variable, thus causing flying entities that are ridden by other players in a multiplayer scenario to also fly along with the one you're riding, even if they didn't tell theirs to fly XD

 

 

well, there's a good news tho. I found a way to fix this multiplayer problem using NBT tags, and I'll be redoing the wrong/inaccurate parts of this tutorial! stay tuned.

Last seen on 14:43, 2. Aug 2022
Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I was gonna say this but you…
Mon, 02/08/2021 - 13:03

I was gonna say this but you beat me to it. Good tutorial anyway.

Last seen on 10:51, 1. Jul 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@DiamondGamin thanks! just…
Mon, 02/08/2021 - 13:54

@DiamondGamin

thanks!

just updated the tutorial btw, so I believe the entire multiplayer problem is fixed. I should really be mindful of what things/procedures I use next time around...

Last seen on 01:30, 11. Oct 2024
Joined Aug 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nice tutorial, I'm sure it…
Thu, 02/11/2021 - 00:52

Nice tutorial, I'm sure it will help some users :D

Last seen on 03:58, 17. Feb 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
For every challenge…
Wed, 02/17/2021 - 03:59

For every challenge encountered there is an opportunity for growth cookie clicker good

Last seen on 20:38, 30. Dec 2022
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is the same method I…
Sun, 03/28/2021 - 02:27

This is the same method I used for turning and accelerating in my mod, Nate's Cars (figured it out myself), although yours is even better because it sets the keybind directly to the nbt of the entity being ridden!

For anyone that wants to do this, it works perfectly in multiplayer, so no worries there!

Finally, I'd suggest the mob to only apply the movement it is being ridden, otherwise you can dismount while holding a key and the entity keeps going (easy fix, just a "Is (entity riding (event entity)) type PlayerEntity").

Last seen on 01:25, 14. Feb 2023
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Where is the "set vector…
Sun, 05/02/2021 - 03:04

Where is the "set vector movement" block?

I searched in entity management and couldn't find it. I also tried searching it in the search bar and still couldn't find it.

Last seen on 10:51, 1. Jul 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
CyberTuttel, are you on 2021…
Sun, 05/02/2021 - 04:58

CyberTuttel, are you on 2021.1? if yes, I believe they've changed it to "attempt to override motion vector of [entity]" on that version, but it should still be under "entity management".

Last seen on 01:25, 14. Feb 2023
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Got it, thank you
Mon, 05/03/2021 - 02:18

Got it, thank you

Last seen on 14:06, 15. Aug 2022
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have a question. In step 1…
Tue, 08/03/2021 - 18:33

I have a question. In step 1, you have 2 photos on which there are 2 places to choose the procedure. Where can I find this in the latest version of mcreator?

Last seen on 10:51, 1. Jul 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
makxspa, that's the "Keybind…
Tue, 08/03/2021 - 23:44

makxspa, that's the "Keybind" mod element you saw, it contains 2 triggers for when a keybind is pressed and when it's released which you can check yourself. i made this tutorial for 2020.5 and now I'm on 2021.1, but it should still be there, perhaps even on the latest snapshot as I don't see a reason why they would remove it

Last seen on 14:06, 15. Aug 2022
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have one more question…
Wed, 08/04/2021 - 10:44

I have one more question. Where in version 2021.1 is the block "Set Movement Vector to vx: vy: vz: " ? But if it's out of the question, is it possible to replace it with something else? 

Last seen on 10:51, 1. Jul 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
uh, have you read the…
Wed, 08/04/2021 - 11:21

uh, have you read the replies in this topic? if yes, you'll know without having to ask me. try to read the 9th reply (the one before the reply that's on top of your first one) and you'll find out