aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMrSimpleJS <54013002+MrSimpleJS@users.noreply.github.com>2026-03-02 06:43:51 +0100
committerGitHub <noreply@github.com>2026-03-02 13:43:51 +0800
commit9e5d9d19ee62085f4e2ab53e7c13e592d9209c97 (patch)
treee5ad402195478c6b99d085758cf49dd8e122fc32
parent109f563daabad56430ac7aafb9e513527db5fc9a (diff)
Implement item drop functionality with Q key (#99)
Added functionality to drop items using the Q key, with support for dropping entire stacks when Ctrl is held. Included checks to prevent dropping items while destroying blocks.
-rw-r--r--Minecraft.Client/Input.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/Minecraft.Client/Input.cpp b/Minecraft.Client/Input.cpp
index c1a3bb31..092b2759 100644
--- a/Minecraft.Client/Input.cpp
+++ b/Minecraft.Client/Input.cpp
@@ -169,6 +169,45 @@ void Input::tick(LocalPlayer *player)
if (iPad == 0 && KMInput.IsKeyDown(VK_SPACE) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP))
jumping = true;
#endif
+
+#ifdef _WINDOWS64
+ // Keyboard drop (Q)
+ // Press Q to drop one item. Hold Ctrl+Q to drop the whole stack.
+ if (iPad == 0 && KMInput.ConsumeKeyPress('Q') && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_DROP) && !menuOpen)
+ {
+ // Prevent dropping while actively destroying a block (fix crash)
+ MultiPlayerGameMode *mpgm = nullptr;
+ if (pMinecraft->localgameModes[iPad] != NULL)
+ {
+ mpgm = dynamic_cast<MultiPlayerGameMode *>(pMinecraft->localgameModes[iPad]);
+ }
+ if (mpgm != nullptr && mpgm->IsDestroying())
+ {
+ // ignore drop while destroying
+ }
+ else
+ {
+ if (player != NULL)
+ {
+ // If CTRL is held, drop the entire stack
+ if (KMInput.IsKeyDown(VK_CONTROL))
+ {
+ shared_ptr<ItemInstance> sel = player->inventory->getSelected();
+ if (sel != NULL)
+ {
+ shared_ptr<ItemInstance> toDrop = player->inventory->removeItem(player->inventory->selected, sel->count);
+ if (toDrop != NULL) player->drop(toDrop, false);
+ }
+ }
+ else
+ {
+ // Drop a single item (Player::drop() will remove 1 from selected)
+ player->drop();
+ }
+ }
+ }
+ }
+#endif
#ifndef _CONTENT_PACKAGE
if (app.GetFreezePlayers()) jumping = false;