Skip to content

Commit

Permalink
fix: 🐛 Fix backpack open keybind to not close backpack screen when ty…
Browse files Browse the repository at this point in the history
…ped into jei search
  • Loading branch information
P3pp3rF1y committed Dec 3, 2023
1 parent fabe86e commit 31944b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
minecraft_version=1.19.2
forge_version=43.2.13
mod_version=3.19.3
mod_version=3.19.4
jei_mc_version=1.19.2-forge
jei_version=11.6.0.+
curios_version=1.19.2-5.1.1.+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 31944b2

Please sign in to comment.