From b4d59142936a78645662e9ab9f16b887d679d655 Mon Sep 17 00:00:00 2001 From: MCbabel Date: Fri, 6 Mar 2026 14:20:43 +0100 Subject: [PATCH] Match creative flying behavior to Java Edition --- Minecraft.Client/LocalPlayer.cpp | 43 ++++++++------------------------ Minecraft.World/Player.cpp | 13 +++++++--- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index cfcf85acc..bd9c707ef 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -252,7 +252,7 @@ void LocalPlayer::aiStep() bool forwardEnoughToContinueSprint = input->ya >= runTreshold; // 4J - altered this slightly to make sure that the joypad returns to below returnTreshold in between registering two movements up to runThreshold - if (onGround && !isSprinting() && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness)) + if ((onGround || abilities.flying) && !isSprinting() && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness)) { if( !wasRunning && forwardEnoughToTriggerSprint ) { @@ -278,7 +278,7 @@ void LocalPlayer::aiStep() } if (isSneaking()) sprintTriggerTime = 0; #ifdef _WINDOWS64 - if (input->sprinting && onGround && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness) && !isSneaking()) + if (input->sprinting && (onGround || abilities.flying) && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness) && !isSneaking()) { setSprinting(true); } @@ -333,13 +333,10 @@ void LocalPlayer::aiStep() if (abilities.flying) { - // yd = 0; - // 4J - note that the 0.42 added for going down is to make it match with what happens when you jump - jumping itself adds 0.42 to yd in Mob::jumpFromGround - if (ullButtonsPressed & (1LL<jumping) { - noJumpDelay = 0; - yd += 0.15; + yd += 0.15f; } // snap y rotation to nearest 90 degree axis aligned value @@ -434,40 +431,22 @@ void LocalPlayer::aiStep() else #endif { - if( isSprinting() ) + flyX = 0.0f; + flyY = 0.0f; + flyZ = 0.0f; + if( ullDpad_filtered & (1LL<x * input->ya; - flyY = (float)viewVector->y * input->ya; - flyZ = (float)viewVector->z * input->ya; - - float scale = ((float)(SPRINT_DURATION - sprintTime))/10.0f; - scale = scale * scale; - if ( scale > 1.0f ) scale = 1.0f; - flyX *= scale; - flyY *= scale; - flyZ *= scale; + flyY = 0.1f; } - else + if( ullDpad_filtered & (1LL<getValue()); @@ -2082,6 +2082,8 @@ void Player::awardStat(Stat *stat, byteArray paramBlob) void Player::jumpFromGround() { + if (abilities.flying) return; + LivingEntity::jumpFromGround(); // 4J Stu - This seems to have been missed from 1.7.3, but do we care? @@ -2104,11 +2106,14 @@ void Player::travel(float xa, float ya) if (abilities.flying && riding == NULL) { - double ydo = yd; + double savedYd = yd; float ofs = flyingSpeed; - flyingSpeed = abilities.getFlyingSpeed(); + flyingSpeed = abilities.getFlyingSpeed() * (isSprinting() ? 2 : 1); + bool wasOnGround = onGround; + onGround = false; LivingEntity::travel(xa, ya); - yd = ydo * 0.6; + onGround = wasOnGround; + yd = savedYd * 0.6; flyingSpeed = ofs; } else