Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 Fixed backpack to just close gui instead of crashing out of wo… #1160

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down