Q to drop

This commit is contained in:
2026-09-25 16:42:19 -03:00
parent a254b96f65
commit d107405f62
6 changed files with 116 additions and 0 deletions
+21
View File
@@ -138,6 +138,9 @@ export class Client {
this.pop_screen();
}
}
if (InputManager.is_key_pressed(options.key_drop)) {
this.#handle_drop();
}
if (InputManager.is_key_pressed(options.key_chat) && !this.screen) {
this.push_screen(new GuiChat(this));
}
@@ -165,6 +168,24 @@ export class Client {
}
}
// the held item while playing, the slot under the mouse in an inventory (only with nothing on the cursor)
#handle_drop() {
const all = InputManager.is_key_down("ControlLeft") || InputManager.is_key_down("ControlRight");
const inventories = this.player.inventories;
const screen = this.screen;
if (!screen) {
this.game_mode.drop_item(inventories.inventory, "inventory", inventories.hotbar_selected, all);
return;
}
const slot = screen instanceof GuiInventoryScreen ? screen.hovering : undefined;
const container = slot && screen instanceof GuiInventoryScreen
? screen.get_container(slot.container)
: undefined;
if (slot && container && !slot.output && !inventories.cursor.item) {
this.game_mode.drop_item(container, slot.container, slot.index, all);
}
}
// clicks happen right away, holding to break advances in tick()
#handle_block_interaction() {
const hit = this.hit_result;