Mod idea - Autojump

Rochambeau
Member
 
Posts: 68
Joined: Tue Sep 23, 2014 11:37

Mod idea - Autojump

by Rochambeau » Sun Oct 19, 2014 07:57

Hi,

i would like to create a mod that, when the player walks near an one block high obstacle, the player automatically jumps. (IIRC this is the common behaviour in MC PE)

The problem is I don't know how to start at all. Is there some code that I could "borrow" from a similar mod?
I guess the mobs mods might have something useful as the animals can walk up hills, but I haven't found the right lines yet.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: Mod idea - Autojump

by 4aiman » Sun Oct 19, 2014 09:51

I wouldn't recommend doing this from lua, but...
You can:
- invoke player:get_yaw()
- read player:get_player_controls().up
- and if there's a node at player:getpos() + vector, received from yaw and the second one is TRUE, then jump.

The only problem is that you can't invoke a jump.
So, I'd not recommend you to continue this way, but...
You can:
- create an entity at player:getpos()
- attach a player to it
- make it jump (see mobs by PilzAdam)
- detach the player and remove the entity.

But. as I've said... look at the android controls. Maybe an autojump option for PC edition won't be so horrible to prevent it from merging.

Regards!
 

User avatar
napodan
Member
 
Posts: 42
Joined: Mon Sep 29, 2014 12:07
GitHub: napodan

Re: Mod idea - Autojump

by napodan » Sun Oct 19, 2014 19:45

I like the idea for android build : it's hard to point, push up and jump without dropping your phone.

For simple mobs, as I understand, when the mob is moving but its velocity is inferior than a certain value (0.5 in normal walk and 1.5 in following walk), you just change the y velocity (which is often null) by 5 or 6. The mob will jump.
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

Re: Mod idea - Autojump

by Calinou » Wed Oct 22, 2014 20:24

Change the step height in the source code. This way, you have something fully client-side, usable on any server, without lag.

localplayer.cpp line 194:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
float player_stepheight = touching_ground ? (BS*0.6) : (BS*0.2)


Change BS*0.6 to BS*1.1 then recompile.

I believe this step height could automatically be used on Android builds, it seems fair considering controls are harder to use there.

camera.cpp line 275:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
      f32 t = exp(-23*frametime);


Change -23 to -7 for more smoothing. -10 is a good value with the default step height, but here we are stepping up larger heights.
 

Ascent
New member
 
Posts: 5
Joined: Thu Sep 18, 2014 05:04

Re: Mod idea - Autojump

by Ascent » Fri Oct 24, 2014 05:26

Calinou wrote:Change the step height in the source code. This way, you have something fully client-side, usable on any server, without lag.

That's really useful. I'm building my client with this from now on. Thanks, Calinou!
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Mod idea - Autojump

by Sokomine » Tue Oct 28, 2014 02:38

Calinou wrote:Change the step height in the source code.

Sounds like a very good idea, especially regarding the android client. It would be great if it could be made configurable.
The drawback is that an increased step height will make braking at the end of roads in fast move more difficult.
A list of my mods can be found here.
 


Return to Modding Discussion

Who is online

Users browsing this forum: Bing [Bot] and 4 guests

cron