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 df12f4f commit 8b1f148
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 @@ -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

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 8b1f148

Please sign in to comment.