Cuberite Forum
Simple doublejump - Printable Version

+- Cuberite Forum (
+-- Forum: Plugins (
+--- Forum: Plugin Discussion (
+--- Thread: Simple doublejump (/thread-2953.html)

Simple doublejump - nrgjrteherh435 - 05-19-2017

So I'm coding a doublejump plugin for my server, and I was wondering what the most optimal way of doing so was.

My current code:
function OnTick(Player, TimeDelta)
    if(not Player.IsOnGround) then
        if(Player.IsSprinting) then
            -- Do Stuff

I haven't really dug into the docs yet, so I'm likely missing something. I know that I would need to track the jump input in the if statement somehow... How would I go about doing that? Also, does IsSprinting get set to false if the player is airborne? And is it smart to be checking this every tick, or is there another hook that would be more optimal?

Please and thank you.

RE: Simple doublejump - xoft - 05-19-2017

I'm afraid any kind of a doublejump plugin would be a hack at best. Currently, there's no way for Cuberite plugins to read the packets sent by the client directly, so there's no way to detect the second press of the jump key (even if the client send it at all (?)).

The IsSprinting flag is taken directly from the client, so whatever the client says, the flag mirrors.

As for your code, the OnTick() hook doesn't get any Player parameter, it gets a World parameter, so you'll need to iterate over all players in the world. Also note that most if not all functions in Cuberite API need to be called using the colon convention - Player:IsOnGround() etc.

RE: Simple doublejump - NiLSPACE - 05-19-2017

I've seen people implement double jumping by detecting if they're flying. It would end up something like this:
if (player is flying) then
   stop player from flying
   set Y speed to make the player go upwards.
You can let players in survival fly by using <player>:SetCanFly(true)

RE: Simple doublejump - Seadragon91 - 05-19-2017

Another idea would be to use AddEntityEffect_1:
a_Player:AddEntityEffect(cEntityEffect.effJumpBoost, 200, 1, 1)
This gives you jump boost 2 with an duration of 10s   Smile

RE: Simple doublejump - NiLSPACE - 05-19-2017

That isn't a double jump though. It might be sufficient depending on what @nrgjrteherh435 wants to have double jump for.