From 2a683c19e41aefa3331cc6fc2b03779aa9a822a2 Mon Sep 17 00:00:00 2001 From: ethxn <163630159+ethxnblxd@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:25:51 +0800 Subject: [PATCH] Add files via upload --- Minecraft.Client/ChatScreen.cpp | 96 +++++++++++++++++++++++++++----- Minecraft.Client/Minecraft.cpp | 99 +++++++++++++++++++++++++++++---- 2 files changed, 169 insertions(+), 26 deletions(-) diff --git a/Minecraft.Client/ChatScreen.cpp b/Minecraft.Client/ChatScreen.cpp index 53c907224..af0071d03 100644 --- a/Minecraft.Client/ChatScreen.cpp +++ b/Minecraft.Client/ChatScreen.cpp @@ -6,6 +6,7 @@ #include "..\Minecraft.World\SharedConstants.h" #include "..\Minecraft.World\StringHelpers.h" #include "..\Minecraft.World\ChatPacket.h" +#include "Windows64\KeyboardMouseInput.h" const wstring ChatScreen::allowedChars = SharedConstants::acceptableLetters; vector ChatScreen::s_chatHistory; @@ -85,24 +86,27 @@ void ChatScreen::handleHistoryDown() void ChatScreen::keyPressed(wchar_t ch, int eventKey) { + if (eventKey == Keyboard::KEY_ESCAPE) - { + { minecraft->setScreen(nullptr); return; } + if (eventKey == Keyboard::KEY_RETURN) - { + { wstring trim = trimString(message); - if (trim.length() > 0) - { + if (!trim.empty()) + { if (!minecraft->handleClientSideCommand(trim)) - { + { MultiplayerLocalPlayer* mplp = dynamic_cast(minecraft->player.get()); if (mplp && mplp->connection) mplp->connection->send(shared_ptr(new ChatPacket(trim))); } + if (s_chatHistory.empty() || s_chatHistory.back() != trim) - { + { s_chatHistory.push_back(trim); if (s_chatHistory.size() > CHAT_HISTORY_MAX) s_chatHistory.erase(s_chatHistory.begin()); @@ -111,33 +115,97 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey) minecraft->setScreen(nullptr); return; } + if (eventKey == Keyboard::KEY_UP) { handleHistoryUp(); return; } if (eventKey == Keyboard::KEY_DOWN) { handleHistoryDown(); return; } + if (eventKey == Keyboard::KEY_LEFT) - { - if (cursorIndex > 0) + { + if (g_KBMInput.IsKeyDown(VK_CONTROL)) + { + // move left by word + while (cursorIndex > 0 && iswspace(message[cursorIndex - 1])) cursorIndex--; + while (cursorIndex > 0 && !iswspace(message[cursorIndex - 1])) cursorIndex--; + } + else if (cursorIndex > 0) + { cursorIndex--; + } return; } + if (eventKey == Keyboard::KEY_RIGHT) - { - if (cursorIndex < static_cast(message.length())) + { + int len = static_cast(message.length()); + if (g_KBMInput.IsKeyDown(VK_CONTROL)) + { + // move right by word + while (cursorIndex < len && !iswspace(message[cursorIndex])) cursorIndex++; + while (cursorIndex < len && iswspace(message[cursorIndex])) cursorIndex++; + } + else if (cursorIndex < len) + { cursorIndex++; + } return; } + + // NEEDS IMPLEMENTING (CTRL + BACKSPACE TO DELETE WORD) + if (eventKey == Keyboard::KEY_BACK && cursorIndex > 0) - { - message.erase(cursorIndex - 1, 1); - cursorIndex--; + { + if (g_KBMInput.IsKeyDown(VK_CONTROL)) + { + return; + } + else + { + message.erase(cursorIndex - 1, 1); + cursorIndex--; + return; + } + + } + + // NEEDS IMPLEMENTING (CTRL + A TO SELECT ALL) + + if (g_KBMInput.IsKeyDown(VK_CONTROL) && g_KBMInput.IsKeyPressed('A')) + { return; } + + // NEEDS IMPLEMENTING (SHIFT + LEFT ARROW TO SELECT CHARACTER) + + if (g_KBMInput.IsKeyDown(VK_SHIFT) && g_KBMInput.IsKeyPressed(VK_LEFT)) + { + return; + } + + // NEEDS IMPLEMENTING (SHIFT + RIGHT ARROW TO SELECT CHARACTER) + + if (g_KBMInput.IsKeyDown(VK_SHIFT) && g_KBMInput.IsKeyPressed(VK_RIGHT)) + { + return; + } + + // NEEDS IMPLEMENTING (TAB TO AUTOFILL USERNAMES e.g( et > TAB > ethxnblxd )) + // if theres multiple usernames then make a gui above the chat window and cycle through them by using tab) + + if (eventKey == Keyboard::KEY_TAB) // NEEDS FIXING OPENS PLAYERLIST IN CHAT WINDOW + { + return; + } + if (isAllowedChatChar(ch) && static_cast(message.length()) < SharedConstants::maxChatLength) - { + { message.insert(cursorIndex, 1, ch); cursorIndex++; } } + +// NEEDS IMPLEMENTING (BLUE CHARACTER SELECTION RENDERING) + void ChatScreen::render(int xm, int ym, float a) { fill(2, height - 14, width - 2, height - 2, 0x80000000); diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 1ba432fd0..e0f327155 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -36,6 +36,8 @@ #include "FrustumCuller.h" #include "Camera.h" +#include "chrono" + #include "..\Minecraft.World\MobEffect.h" #include "..\Minecraft.World\Difficulty.h" #include "..\Minecraft.World\net.minecraft.world.level.h" @@ -1509,10 +1511,42 @@ void Minecraft::run_middle() } } - if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DROP)) - localplayers[i]->ullButtonsPressed|=1LL<ullButtonsPressed |= 1LL << MINECRAFT_ACTION_DROPALL; + } + + else if (down) + // CHANGED FROM IsKeyPressed SO YOU CAN HOLD TO DROP (after 0.3 sec delay). + { + auto now = std::chrono::steady_clock::now(); + + if (!wasDown) + { + // first press + localplayers[i]->ullButtonsPressed |= 1LL << MINECRAFT_ACTION_DROP; + pressTime = now; + } + else + { + float held = std::chrono::duration(now - pressTime).count(); + + if (held > 0.3f) + { + localplayers[i]->ullButtonsPressed |= 1LL << MINECRAFT_ACTION_DROP; + } + } + } + + wasDown = down; + + if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING)) { if((ui.IsSceneInStack(i, eUIScene_Crafting2x2Menu) || ui.IsSceneInStack(i, eUIScene_Crafting3x3Menu) || ui.IsSceneInStack(i, eUIScene_CreativeMenu) || isClosableByEitherKey) && !isEditing) { @@ -1524,18 +1558,27 @@ void Minecraft::run_middle() } } - for (int slot = 0; slot < 9; slot++) + // PREVENTS SWITCHING HOTBAR SLOTS WHEN IN MENUS + + if (!ui.GetMenuDisplayed(0)) { - if (g_KBMInput.IsKeyPressed('1' + slot)) + for (int slot = 0; slot < 9; slot++) { - if (localplayers[i]->inventory) - localplayers[i]->inventory->selected = slot; + if (g_KBMInput.IsKeyPressed('1' + slot)) + { + if (localplayers[i]->inventory) + localplayers[i]->inventory->selected = slot; + } } } + } + // Utility keys always work regardless of KBM active state - if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE) && !ui.GetMenuDisplayed(i)) + Minecraft* pMinecraft = Minecraft::GetInstance(); + + if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE) && !ui.GetMenuDisplayed(i) && pMinecraft->screen == NULL) { localplayers[i]->ullButtonsPressed|=1LL<ullButtonsPressed&(1LL<isInputAllowed(MINECRAFT_ACTION_INVENTORY)) { shared_ptr player = Minecraft::GetInstance()->player; - if (!player->isRiding()) - { - ui.PlayUISFX(eSFX_Press); - } + ui.PlayUISFX(eSFX_Press); if(gameMode->isServerControlledInventory()) { @@ -3805,6 +3875,11 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) player->drop(); } + if((player->ullButtonsPressed&(1LL<isInputAllowed(MINECRAFT_ACTION_DROPALL)) + { + player->dropall(); + } + uint64_t ullButtonsPressed=player->ullButtonsPressed; bool selected = false;