genandnic / Wall-Jump

https://www.curseforge.com/minecraft/mc-mods/wall-jump
14 stars 23 forks source link

Player can jump two blocks high while sprinting #5

Closed genandnic closed 4 years ago

spascou commented 4 years ago

That issue comes from the port of the following part (https://github.com/genandnic/Wall-Jump/blob/1.15/src/main/java/genandnic/walljump/client/SpeedBoostLogic.java#L24-L27):

        int jumpBoostLevel = 0;
        EffectInstance jumpBoostEffect = pl.getActivePotionEffect(Effect.get(8));
        if (jumpBoostEffect != null) jumpBoostLevel = jumpBoostEffect.getAmplifier() + 1;
        pl.jumpMovementFactor = (float) (pl.getAIMoveSpeed() * (pl.isSprinting() ? 1 : 1.3) / 5) * (jumpBoostLevel * 0.5f + 1);

@genandnic could you please explain to me what's the objective of this code? I take it gets the active level of the vanilla jump boost potion effect and then overrides the jumpMovementFactor based on movement speed, whether the player is sprinting or not and the previously obtained jumpBoostLevel. But how is jumpMovementFactor related to aiMoveSpeed ?

Sadly I fail to find anything matching this jumpMovementFactor in ClientPlayerEntity on Fabric decompiled mapped sources. getAIMoveSpeed seems to simply be getMovementSpeed on my side.

I might be able to replicate behavior in another place though, but I fail to understand this part.

spascou commented 4 years ago

For whatever reason that appears to be flyingSpeed on Yarn mappings -- I'll try to fix it using that.

genandnic commented 4 years ago

So it really bothered me that the player's airspeed did not scale with the players ground speed in vanilla minecraft. For example, after you drink a speed boost potion in the base game it's actually slower to jump while sprinting (without the potion it's faster). Or when you drink a jump boost potion your jump height increases but the distance traveled horizontally stays the same, which makes the effect kinda boring.

The tweak is really subtle, though. If the variable isn't available I'd just remove that block entirely. It doesn't have anything to do with the speed boost enchantments anyway, they'd be completely unaffected.

spascou commented 4 years ago

Thanks for the explanation -- indeed I never really noticed it but it does make Potion of Leaping way more nice to use now.

I found a way to fix it :D beta3 incoming with the fix.

spascou commented 4 years ago

Fixed on: https://github.com/genandnic/Wall-Jump/releases/tag/fabric-1.3.3-beta.3 by: https://github.com/genandnic/Wall-Jump/commit/f005425450b5134e8275843e7239f381a8cb17b7