aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt
blob: e03126fde55584751cdc66d4ce88be7dc822a13f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

class AnvilCombineHelper {

    @SubscribeEvent
    fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
        if (!LorenzUtils.inSkyBlock) return
        if (!SkyHanniMod.feature.inventory.anvilCombineHelper) return

        if (event.gui !is GuiChest) return
        val chest = event.gui.inventorySlots as ContainerChest
        val chestName = chest.getInventoryName()

        if (chestName != "Anvil") return

        val matchLore = mutableListOf<String>()
//        var compareItem: ItemStack? = null

        for (slot in chest.inventorySlots) {
            if (slot == null) continue

            if (slot.slotNumber != slot.slotIndex) continue
            if (slot.stack == null) continue

            if (slot.slotNumber == 29) {
//                slot highlight LorenzColor.GREEN
                val lore = slot.stack.getLore()
//                compareItem = slot.stack
                matchLore.addAll(lore)
                break
//            } else if (slot.slotIndex == 29) {
//                slot highlight LorenzColor.YELLOW
            }
        }

        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()) {
                slot highlight LorenzColor.GREEN
            }

//            if (compareItem == slot.stack) {
//                slot highlight LorenzColor.GREEN
//            } else if (compareItem.metadata == slot.stack.metadata) {
//                slot highlight LorenzColor.YELLOW
//            }

//            if (slot.slotNumber == 3) {
////                slot highlight LorenzColor.GREEN
////            } else if (slot.slotIndex == 4) {
////                slot highlight LorenzColor.YELLOW
////            }
//            }
        }
    }
}