From c774e1eb18b48fffc5b902853497f4ea94df228b Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Tue, 10 Mar 2026 22:42:14 -0500 Subject: [PATCH 1/3] feat(input): add sprint keys --- 4J.Input/4J_Input.cpp | 9 ++++++--- Minecraft.Client/Input/Input.cpp | 9 +++------ Minecraft.Client/Input/Input.h | 1 + Minecraft.Client/Platform/Common/App_enums.h | 1 + Minecraft.Client/Player/LocalPlayer.cpp | 13 ++++++++++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/4J.Input/4J_Input.cpp b/4J.Input/4J_Input.cpp index 2ed4de5e4..012d385e5 100644 --- a/4J.Input/4J_Input.cpp +++ b/4J.Input/4J_Input.cpp @@ -215,7 +215,8 @@ bool C_4JInput::ButtonDown(int iPad, unsigned char ucAction) { switch (ucAction) { case MINECRAFT_ACTION_ACTION: return MouseLDown() || KDown(SDL_SCANCODE_RETURN); case MINECRAFT_ACTION_USE: return MouseRDown() || KDown(SDL_SCANCODE_F); - case MINECRAFT_ACTION_SNEAK_TOGGLE: return KDown(SDL_SCANCODE_LSHIFT) || KDown(SDL_SCANCODE_RSHIFT) || KDown(SDL_SCANCODE_LCTRL) || KDown(SDL_SCANCODE_RCTRL); + case MINECRAFT_ACTION_SNEAK_TOGGLE: return KDown(SDL_SCANCODE_LSHIFT) || KDown(SDL_SCANCODE_RSHIFT); + case MINECRAFT_ACTION_SPRINT: return KDown(SDL_SCANCODE_LCTRL) || KDown(SDL_SCANCODE_RCTRL); case MINECRAFT_ACTION_LEFT_SCROLL: case ACTION_MENU_LEFT_SCROLL: return ScrollSnap() > 0; case MINECRAFT_ACTION_RIGHT_SCROLL: @@ -229,7 +230,8 @@ bool C_4JInput::ButtonPressed(int iPad, unsigned char ucAction) { switch (ucAction) { case MINECRAFT_ACTION_ACTION: return MouseLPressed() || KPressed(SDL_SCANCODE_RETURN); case MINECRAFT_ACTION_USE: return MouseRPressed() || KPressed(SDL_SCANCODE_F); - case MINECRAFT_ACTION_SNEAK_TOGGLE: return KPressed(SDL_SCANCODE_LSHIFT) || KPressed(SDL_SCANCODE_RSHIFT) || KPressed(SDL_SCANCODE_LCTRL) || KPressed(SDL_SCANCODE_RCTRL); + case MINECRAFT_ACTION_SNEAK_TOGGLE: return KPressed(SDL_SCANCODE_LSHIFT) || KPressed(SDL_SCANCODE_RSHIFT); + case MINECRAFT_ACTION_SPRINT: return KPressed(SDL_SCANCODE_LCTRL) || KPressed(SDL_SCANCODE_RCTRL); case MINECRAFT_ACTION_LEFT_SCROLL: case ACTION_MENU_LEFT_SCROLL: return ScrollSnap() > 0; case MINECRAFT_ACTION_RIGHT_SCROLL: @@ -243,7 +245,8 @@ bool C_4JInput::ButtonReleased(int iPad, unsigned char ucAction) { switch (ucAction) { case MINECRAFT_ACTION_ACTION: return MouseLReleased() || KReleased(SDL_SCANCODE_RETURN); case MINECRAFT_ACTION_USE: return MouseRReleased() || KReleased(SDL_SCANCODE_F); - case MINECRAFT_ACTION_SNEAK_TOGGLE: return KReleased(SDL_SCANCODE_LSHIFT) || KReleased(SDL_SCANCODE_RSHIFT) || KReleased(SDL_SCANCODE_LCTRL) || KReleased(SDL_SCANCODE_RCTRL); + case MINECRAFT_ACTION_SNEAK_TOGGLE: return KReleased(SDL_SCANCODE_LSHIFT) || KReleased(SDL_SCANCODE_RSHIFT); + case MINECRAFT_ACTION_SPRINT: KReleased(SDL_SCANCODE_LCTRL) || KReleased(SDL_SCANCODE_RCTRL); case MINECRAFT_ACTION_LEFT_SCROLL: case ACTION_MENU_LEFT_SCROLL: case MINECRAFT_ACTION_RIGHT_SCROLL: diff --git a/Minecraft.Client/Input/Input.cpp b/Minecraft.Client/Input/Input.cpp index 3349b8381..439a0e536 100644 --- a/Minecraft.Client/Input/Input.cpp +++ b/Minecraft.Client/Input/Input.cpp @@ -15,6 +15,7 @@ Input::Input() wasJumping = false; jumping = false; sneaking = false; + sprintKey = false; lReset = false; rReset = false; @@ -103,12 +104,8 @@ void Input::tick(LocalPlayer *player) //jumping = controller.isButtonPressed(0); - - unsigned int jump = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP); - if( jump > 0 && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP) ) - jumping = true; - else - jumping = false; + sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SPRINT); + jumping = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP); #ifndef _CONTENT_PACKAGE if (app.GetFreezePlayers()) jumping = false; diff --git a/Minecraft.Client/Input/Input.h b/Minecraft.Client/Input/Input.h index daac8bf6d..d30df79a2 100644 --- a/Minecraft.Client/Input/Input.h +++ b/Minecraft.Client/Input/Input.h @@ -10,6 +10,7 @@ public: bool wasJumping; bool jumping; bool sneaking; + bool sprintKey; Input(); // 4J - added virtual ~Input(){} diff --git a/Minecraft.Client/Platform/Common/App_enums.h b/Minecraft.Client/Platform/Common/App_enums.h index b6c484dc8..d4f639e05 100644 --- a/Minecraft.Client/Platform/Common/App_enums.h +++ b/Minecraft.Client/Platform/Common/App_enums.h @@ -828,6 +828,7 @@ enum EControllerActions MINECRAFT_ACTION_PAUSEMENU, MINECRAFT_ACTION_DROP, MINECRAFT_ACTION_SNEAK_TOGGLE, + MINECRAFT_ACTION_SPRINT, MINECRAFT_ACTION_CRAFTING, MINECRAFT_ACTION_RENDER_THIRD_PERSON, MINECRAFT_ACTION_GAME_INFO, diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index dee185522..9653cf19e 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -305,7 +305,7 @@ void LocalPlayer::aiStep() // 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( !wasRunning && input->ya >= runTreshold ) + if( !wasRunning && (input->ya >= runTreshold) ) { if (sprintTriggerTime == 0) { @@ -316,6 +316,7 @@ void LocalPlayer::aiStep() { if( sprintTriggerRegisteredReturn ) { + printf("setSprinting true\n"); setSprinting(true); sprintTriggerTime = 0; sprintTriggerRegisteredReturn = false; @@ -326,14 +327,20 @@ void LocalPlayer::aiStep() { sprintTriggerRegisteredReturn = true; } + else if (input->sprintKey) + { + printf("setSprinting true\n"); + setSprinting(true); + } } if (isSneaking()) sprintTriggerTime = 0; // 4J-PB - try not stopping sprint on collision //if (isSprinting() && (input->ya < runTreshold || horizontalCollision || !enoughFoodToSprint)) - if (isSprinting() && (input->ya < runTreshold || !enoughFoodToSprint)) + if (isSprinting() && ((input->ya < runTreshold && !input->sprintKey) || !enoughFoodToSprint)) { + printf("setSprinting false\n"); setSprinting(false); - } + } // 4J Stu - Fix for #52705 - Customer Encountered: Player can fly in bed while being in Creative mode. if (!isSleeping() && (abilities.mayfly || isAllowedToFly() )) From 559cdfd2810ad95e345b43c9cfcfe14e45abe7dd Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:31:13 -0500 Subject: [PATCH 2/3] chore: remove test prints --- Minecraft.Client/Player/LocalPlayer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index 9653cf19e..d2b4cb83c 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -316,7 +316,6 @@ void LocalPlayer::aiStep() { if( sprintTriggerRegisteredReturn ) { - printf("setSprinting true\n"); setSprinting(true); sprintTriggerTime = 0; sprintTriggerRegisteredReturn = false; @@ -329,7 +328,6 @@ void LocalPlayer::aiStep() } else if (input->sprintKey) { - printf("setSprinting true\n"); setSprinting(true); } } From 19bc286818ab1f9fb5e2864bf6eecc28fcd0faeb Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:33:12 -0500 Subject: [PATCH 3/3] chore: remove another test print --- Minecraft.Client/Player/LocalPlayer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index d2b4cb83c..91adb3300 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -336,7 +336,6 @@ void LocalPlayer::aiStep() //if (isSprinting() && (input->ya < runTreshold || horizontalCollision || !enoughFoodToSprint)) if (isSprinting() && ((input->ya < runTreshold && !input->sprintKey) || !enoughFoodToSprint)) { - printf("setSprinting false\n"); setSprinting(false); }