Mod idea - Autojump

Post Reply
Rochambeau
Member
Posts: 119
Joined: Tue Sep 23, 2014 11:37

Mod idea - Autojump

by Rochambeau » Post

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 » Post

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
Location: Asnieres/France

Re: Mod idea - Autojump

by napodan » Post

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: 3168
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou
Location: Troyes, France
Contact:

Re: Mod idea - Autojump

by Calinou » Post

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:

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:

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 » Post

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: 4317
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: Mod idea - Autojump

by Sokomine » Post

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.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests