diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-04 21:19:40 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-05 01:12:48 +0800 |
| commit | 1dc8a005ed111463c22c17b487e5ec8a3e2d30f3 (patch) | |
| tree | 8f1825364bf14178f720ee124b01de78afa16d40 /Minecraft.Client/LocalPlayer.cpp | |
| parent | ac03b88a907bb49f5159f08de07398f3fce32991 (diff) | |
refactor: refactor KBM input code
Diffstat (limited to 'Minecraft.Client/LocalPlayer.cpp')
| -rw-r--r-- | Minecraft.Client/LocalPlayer.cpp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index bb25105f..77306621 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -251,13 +251,10 @@ void LocalPlayer::aiStep() if (changingDimensionDelay > 0) changingDimensionDelay--; bool wasJumping = input->jumping; float runTreshold = 0.8f; - float sprintForward = input->sprintForward; - - bool wasRunning = sprintForward >= runTreshold; + bool wasRunning = input->ya >= runTreshold; //input->tick( dynamic_pointer_cast<Player>( shared_from_this() ) ); // 4J-PB - make it a localplayer input->tick( this ); - sprintForward = input->sprintForward; if (isUsingItem() && !isRiding()) { input->xa *= 0.2f; @@ -281,25 +278,9 @@ void LocalPlayer::aiStep() // world with low food, then reload it in creative. if(abilities.mayfly || isAllowedToFly() ) enoughFoodToSprint = true; - bool forwardEnoughToTriggerSprint = sprintForward >= runTreshold; - bool forwardReturnedToDeadzone = sprintForward == 0.0f; - bool forwardEnoughToContinueSprint = sprintForward >= runTreshold; - -#ifdef _WINDOWS64 - if (GetXboxPad() == 0 && input->usingKeyboardMovement) - { - forwardEnoughToContinueSprint = sprintForward > 0.0f; - } -#endif - -#ifdef _WINDOWS64 - // Keyboard sprint: Ctrl held while moving forward - if (GetXboxPad() == 0 && input->usingKeyboardMovement && KMInput.IsKeyDown(VK_CONTROL) && sprintForward > 0.0f && - enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness) && onGround) - { - if (!isSprinting()) setSprinting(true); - } -#endif + bool forwardEnoughToTriggerSprint = input->ya >= runTreshold; + bool forwardReturnedToDeadzone = input->ya == 0.0f; + 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)) @@ -327,6 +308,12 @@ void LocalPlayer::aiStep() } } if (isSneaking()) sprintTriggerTime = 0; +#ifdef _WINDOWS64 + if (input->sprinting && onGround && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness) && !isSneaking()) + { + setSprinting(true); + } +#endif // 4J-PB - try not stopping sprint on collision //if (isSprinting() && (input->ya < runTreshold || horizontalCollision || !enoughFoodToSprint)) if (isSprinting() && (!forwardEnoughToContinueSprint || !enoughFoodToSprint || isSneaking() || isUsingItem())) |
