diff --git a/gradle.properties b/gradle.properties index 7dc02697..90283d24 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ loader_version_range=[4,) mod_id=sophisticatedbackpacks mod_name=Sophisticated Backpacks mod_license=GNU General Public License v3.0 -mod_version=3.20.14 +mod_version=3.20.15 mod_group_id=sophisticatedbackpacks mod_authors=P3pp3rF1y, Ridanisaurus mod_description=Fancy and functional backpacks. @@ -34,7 +34,7 @@ chipped_cf_file_id=5506938 resourcefullib_cf_file_id=5483169 athena_cf_file_id=5431579 curios_cf_file_id=5546342 -sc_version=[1.21,1.22) +sc_version=[1.21-0.6.39,1.22) #publish curseforge_id=422301 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 99507845..cb756a5f 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java @@ -1,6 +1,8 @@ package net.p3pp3rf1y.sophisticatedbackpacks.client.gui; import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.InventoryScreen; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; @@ -52,4 +54,12 @@ private boolean mouseNotOverBackpack() { protected String getStorageSettingsTabTooltip() { return SBPTranslationHelper.INSTANCE.translGui("settings.tooltip"); } + + @Override + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { + super.render(guiGraphics, mouseX, mouseY, partialTicks); + if (getMenu().getNumberOfStorageInventorySlots() == 0 && Minecraft.getInstance().player != null) { + Minecraft.getInstance().player.closeContainer(); + } + } } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/gui/BackpackContext.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/gui/BackpackContext.java index 9d11be2f..194c7575 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/gui/BackpackContext.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/gui/BackpackContext.java @@ -155,7 +155,12 @@ public IBackpackWrapper getBackpackWrapper(Player player) { SophisticatedBackpacks.LOGGER.error("Error getting backpack wrapper - Unable to find inventory handler for \"{}\"", handlerName); return IBackpackWrapper.Noop.INSTANCE; } - return BackpackWrapper.fromStack(inventoryHandler.get().getStackInSlot(player, identifier, backpackSlotIndex)); + ItemStack backpackStack = inventoryHandler.get().getStackInSlot(player, identifier, backpackSlotIndex); + if (backpackStack.getItem() instanceof BackpackItem) { + return BackpackWrapper.fromStack(backpackStack); + } + SophisticatedBackpacks.LOGGER.error("Error getting backpack wrapper - Stack isn't a backpack"); + return IBackpackWrapper.Noop.INSTANCE; } @Override