From b808a6aea1ba28ffd10712e7586b6f0d6cc1804a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:04:56 +0100 Subject: Internal Change: Code cleanup ContainerChest getAllItems (#1047) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/features/anvil/AnvilCombineHelper.kt | 23 +++++++--------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/anvil') diff --git a/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt index eddd232bd..9e9992ab1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt @@ -3,6 +3,8 @@ package at.hannibal2.skyhanni.features.anvil import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName +import at.hannibal2.skyhanni.utils.InventoryUtils.getLowerItems +import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils @@ -26,14 +28,9 @@ class AnvilCombineHelper { val matchLore = mutableListOf() - for (slot in chest.inventorySlots) { - if (slot == null) continue - - if (slot.slotNumber != slot.slotIndex) continue - if (slot.stack == null) continue - + for ((slot, stack) in chest.getUpperItems()) { if (slot.slotNumber == 29) { - val lore = slot.stack.getLore() + val lore = stack.getLore() matchLore.addAll(lore) break } @@ -41,16 +38,10 @@ class AnvilCombineHelper { if (matchLore.isEmpty()) return - for (slot in chest.inventorySlots) { - if (slot == null) continue - - if (slot.slotNumber == slot.slotIndex) continue - if (slot.stack == null) continue - - - if (matchLore == slot.stack.getLore()) { + for ((slot, stack) in chest.getLowerItems()) { + if (matchLore == stack.getLore()) { slot highlight LorenzColor.GREEN } } } -} \ No newline at end of file +} -- cgit