From 1552ad1b68a04078f9b5374958f45f613436e777 Mon Sep 17 00:00:00 2001 From: querns <33518699+querns@users.noreply.github.com> Date: Sat, 25 Oct 2025 08:45:46 -0500 Subject: [PATCH] Adds configurable display of backpack fullness (#101) --- src/main/java/forestry/core/config/Config.java | 4 ++++ .../java/forestry/storage/items/ItemBackpack.java | 13 +++++++++++++ src/main/resources/assets/forestry/lang/en_US.lang | 1 + 3 files changed, 18 insertions(+) diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index a355456db..c63cd6f9f 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -137,6 +137,7 @@ public class Config { public static boolean enableHints = true; public static final LinkedListMultimap hints = LinkedListMultimap.create(); public static boolean enableEnergyStat = true; + public static boolean showBackpackDurability = true; public static boolean isStructureEnabled(String uid) { return !Config.disabledStructures.contains(uid); @@ -301,6 +302,9 @@ public class Config { configCommon.moveProperty("tweaks.gui", "mail.alert", "tweaks.gui.mail.alert"); configCommon.renameProperty("tweaks.gui.mail.alert", "mail.alert", "enabled"); + showBackpackDurability = configCommon + .getBooleanLocalized("tweaks.gui", "showBackpackDurability", showBackpackDurability); + mailAlertEnabled = configCommon.getBooleanLocalized("tweaks.gui.mail.alert", "enabled", mailAlertEnabled); mailAlertXPosition = configCommon.getEnumLocalized( "tweaks.gui.mail.alert", diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index 141caf38d..80598a7fe 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -348,4 +348,17 @@ public class ItemBackpack extends ItemWithGui { return null; } } + + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + final int occupied = ItemInventory.getOccupiedSlotCount(stack); + final int max = getBackpackSize(); + + return 1.0d - (occupied + 1.0d) / (max + 1.0d); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return Config.showBackpackDurability && ItemInventory.getOccupiedSlotCount(stack) > 0; + } } diff --git a/src/main/resources/assets/forestry/lang/en_US.lang b/src/main/resources/assets/forestry/lang/en_US.lang index ca6f27cb4..1e6f99058 100644 --- a/src/main/resources/assets/forestry/lang/en_US.lang +++ b/src/main/resources/assets/forestry/lang/en_US.lang @@ -1781,6 +1781,7 @@ for.config.crafting.stamps.disabled.comment=Disables the crafting recipe for cer for.config.tweaks=Tweaks +for.config.tweaks.gui.showBackpackDurability=Shows a durability bar on backpacks indicating how full they are. for.config.tweaks.gui.mail.alert.enabled=Mail Alert for.config.tweaks.gui.mail.alert.enabled.comment=Enables the new mail alert box. for.config.tweaks.gui.mail.alert.xPosition=Horizontal Position