From 8b1f1487b25d7c0d2be9dc4b01cd77a11cb5ac40 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Sun, 3 Dec 2023 01:22:07 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20backpack=20open=20k?= =?UTF-8?q?eybind=20to=20not=20close=20backpack=20screen=20when=20typed=20?= =?UTF-8?q?into=20jei=20search?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../client/KeybindHandler.java | 13 +++---------- .../client/gui/BackpackScreen.java | 10 +++++++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/gradle.properties b/gradle.properties index a699f83f..fd84b704 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=sophisticatedbackpacks mod_group_id=sophisticatedbackpacks -mod_version=3.19.3 +mod_version=3.19.4 sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/KeybindHandler.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/KeybindHandler.java index 2f40fa6d..7e52ad36 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/KeybindHandler.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/KeybindHandler.java @@ -199,16 +199,9 @@ private static boolean sendBackpackOpenOrCloseMessage() { return true; } } - if (screen instanceof BackpackScreen) { - if (slot != null && slot.getItem().getItem() instanceof BackpackItem) { - if (slot.getItem().getCount() == 1) { - SBPPacketHandler.INSTANCE.sendToServer(new BackpackOpenMessage(slot.index)); - return true; - } - } else { - SBPPacketHandler.INSTANCE.sendToServer(new BackpackCloseMessage()); - return true; - } + if (screen instanceof BackpackScreen && slot != null && slot.getItem().getItem() instanceof BackpackItem && slot.getItem().getCount() == 1) { + SBPPacketHandler.INSTANCE.sendToServer(new BackpackOpenMessage(slot.index)); + return true; } } return false; diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java index fd371718..ccb9166a 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java @@ -24,9 +24,13 @@ public BackpackScreen(BackpackContainer screenContainer, Inventory inv, Componen @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (keyCode == 256 || KeybindHandler.BACKPACK_OPEN_KEYBIND.isActiveAndMatches(InputConstants.getKey(keyCode, scanCode))) { - if (getMenu().isFirstLevelStorage() && getMenu().getBackpackContext().wasOpenFromInventory() && (keyCode == 256 || mouseNotOverBackpack())) { - getMinecraft().player.closeContainer(); - getMinecraft().setScreen(new InventoryScreen(getMinecraft().player)); + if (getMenu().isFirstLevelStorage() && (keyCode == 256 || mouseNotOverBackpack())) { + if (getMenu().getBackpackContext().wasOpenFromInventory()) { + getMinecraft().player.closeContainer(); + getMinecraft().setScreen(new InventoryScreen(getMinecraft().player)); + } else { + onClose(); + } return true; } else if (!getMenu().isFirstLevelStorage()) { SBPPacketHandler.INSTANCE.sendToServer(new BackpackOpenMessage());