From 078b590dcf93b221abdda2b4c0f4ecc3ab49ba88 Mon Sep 17 00:00:00 2001 From: ghostflyby Pan Date: Thu, 3 Aug 2023 21:15:32 +0800 Subject: [PATCH] fix DarkSteel and other EIO items display (#7) Co-authored-by: ghostflyby --- .../render/DurabilityRenderer.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/caedis/duradisplay/render/DurabilityRenderer.java b/src/main/java/com/caedis/duradisplay/render/DurabilityRenderer.java index 626e57a..c8facbd 100644 --- a/src/main/java/com/caedis/duradisplay/render/DurabilityRenderer.java +++ b/src/main/java/com/caedis/duradisplay/render/DurabilityRenderer.java @@ -318,11 +318,25 @@ private static List handleEnergyContainer(@NotNull ItemStack s // handles all other EIO items private static List handleDarkSteelItems(@NotNull ItemStack stack) { + + Item item = stack.getItem(); + assert item != null; + List overlays = new ArrayList<>(); - List defaultOverlays = handleDefault(stack); - if (defaultOverlays != null) { - overlays.addAll(defaultOverlays); + + if (DuraDisplayConfig.DurabilityConfig.Enabled + && !(DuraDisplayConfig.DurabilityConfig.ShowWhenFull && (stack.getItemDamage() == stack.getMaxDamage()))) { + + ItemStackOverlay durabilityOverlay = new ItemStackOverlay.DurabilityOverlay(); + double durability = (1 - item.getDurabilityForDisplay(stack)); + if (Double.isNaN(durability)) return null; + durabilityOverlay.color = getRGBDurabilityForDisplay(durability); + durability *= 100; + durabilityOverlay.isFull = durability == 100.0; + durabilityOverlay.value = nf.format(durability) + "%"; + overlays.add(durabilityOverlay); } + if (!DuraDisplayConfig.ChargeConfig.Enabled || !stack.hasTagCompound()) return overlays; NBTTagCompound nbt = stack.getTagCompound();