aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt21
4 files changed, 13 insertions, 53 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt
index 298717720..84ca5b235 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt
@@ -57,9 +57,9 @@ class AnitaMedalProfit {
inInventory = true
val table = mutableListOf<DisplayTableEntry>()
- for ((_, item) in event.inventoryItems) {
+ for ((slot, item) in event.inventoryItems) {
try {
- readItem(item, table)
+ readItem(slot, item, table)
} catch (e: Throwable) {
ErrorManager.logErrorWithData(
e, "Error in AnitaMedalProfit while reading item '${item.itemName}'",
@@ -76,7 +76,7 @@ class AnitaMedalProfit {
display = newList
}
- private fun readItem(item: ItemStack, table: MutableList<DisplayTableEntry>) {
+ private fun readItem(slot: Int, item: ItemStack, table: MutableList<DisplayTableEntry>) {
val itemName = getItemName(item) ?: return
if (itemName == " ") return
if (itemName == "§cClose") return
@@ -108,7 +108,7 @@ class AnitaMedalProfit {
"§7Material cost: §6${NumberUtil.format(fullCost)} ",
"§7Final profit: §6${profitFormat} ",
)
- table.add(DisplayTableEntry(itemName, "$color$profitFormat", profit, internalName, hover))
+ table.add(DisplayTableEntry(itemName, "$color$profitFormat", profit, internalName, hover, highlightsOnHoverSlots = listOf(slot)))
}
private fun getItemName(item: ItemStack): String? {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt
index 69c551d74..9e5ec780c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt
@@ -64,23 +64,23 @@ class SkyMartCopperPrice {
inInventory = true
val table = mutableListOf<DisplayTableEntry>()
- for (stack in event.inventoryItems.values) {
- val lore = stack.getLore()
- val otherItemsPrice = stack.loreCosts().sumOf { it.getPrice() }.takeIf { it != -1.0 }
+ for ((slot, item) in event.inventoryItems) {
+ val lore = item.getLore()
+ val otherItemsPrice = item.loreCosts().sumOf { it.getPrice() }.takeIf { it != -1.0 }
for (line in lore) {
val copper = copperPattern.matchMatcher(line) {
group("amount").formatInt()
} ?: continue
- val internalName = stack.getInternalName()
+ val internalName = item.getInternalName()
val lowestBin = internalName.getPriceOrNull() ?: continue
val profit = lowestBin - (otherItemsPrice ?: 0.0)
val factor = profit / copper
val perFormat = NumberUtil.format(factor)
- val itemName = stack.itemName
+ val itemName = item.itemName
val hover = buildList {
add(itemName)
add("")
@@ -93,7 +93,7 @@ class SkyMartCopperPrice {
add("§7Copper amount: §c${copper.addSeparators()} ")
add("§7Profit per copper: §6${perFormat} ")
}
- table.add(DisplayTableEntry("$itemName§f:", "§6§l$perFormat", factor, internalName, hover))
+ table.add(DisplayTableEntry("$itemName§f:", "§6§l$perFormat", factor, internalName, hover, highlightsOnHoverSlots = listOf(slot)))
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt
index 381f46dca..f0b1418ba 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt
@@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.inventory.ChestValueConfig.NumberFormatEntry
import at.hannibal2.skyhanni.config.features.inventory.ChestValueConfig.SortingTypeEntry
import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryOpenEvent
@@ -23,18 +22,14 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
-import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
-import at.hannibal2.skyhanni.utils.SpecialColour
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
-import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import java.awt.Color
class ChestValue {
@@ -82,22 +77,6 @@ class ChestValue {
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
chestItems.clear()
- Renderable.list.clear()
- }
-
- @SubscribeEvent(priority = EventPriority.LOW)
- fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
- if (!isEnabled()) return
- if (!config.enableHighlight) return
- if (inInventory) {
- for ((_, indexes) in Renderable.list) {
- for (slot in InventoryUtils.getItemsInOpenChest()) {
- if (indexes.contains(slot.slotIndex)) {
- slot highlight Color(SpecialColour.specialToChromaRGB(config.highlightColor), true)
- }
- }
- }
- }
}
private fun update() {
@@ -141,7 +120,7 @@ class ChestValue {
text,
tips,
stack = stack,
- indexes = index
+ highlightsOnHoverSlots = if (config.enableHighlight) index else emptyList()
)
add(" §7- ")
if (config.showStacks) add(stack)
@@ -156,7 +135,7 @@ class ChestValue {
SortingTypeEntry.DESCENDING -> chestItems.values.sortedByDescending { it.total }
SortingTypeEntry.ASCENDING -> chestItems.values.sortedBy { it.total }
else -> chestItems.values.sortedByDescending { it.total }
- }.toMutableList()
+ }
private fun addButton(newDisplay: MutableList<List<Any>>) {
newDisplay.addButton("§7Sorted By: ",
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt
index 98649093d..88269a643 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt
@@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.features.rift.everywhere.motes
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.rift.motes.RiftInventoryValueConfig.NumberFormatEntry
-import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
@@ -16,18 +15,15 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.ConfigUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
-import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
-import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class ShowMotesNpcSellPrice {
@@ -63,20 +59,6 @@ class ShowMotesNpcSellPrice {
processItems()
}
- @SubscribeEvent(priority = EventPriority.LOW)
- fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
- if (!isInventoryValueEnabled()) return
- val name = InventoryUtils.openInventoryName()
- if (!name.contains("Rift Storage")) return
- for ((_, indexes) in Renderable.list) {
- for (slot in InventoryUtils.getItemsInOpenChest()) {
- if (indexes.contains(slot.slotIndex)) {
- slot highlight LorenzColor.GREEN
- }
- }
- }
- }
-
@SubscribeEvent
fun onTooltip(event: LorenzToolTipEvent) {
if (!isShowPriceEnabled()) return
@@ -109,7 +91,6 @@ class ShowMotesNpcSellPrice {
itemMap.clear()
slotList.clear()
inInventory = false
- Renderable.list.clear()
}
private fun processItems() {
@@ -165,7 +146,7 @@ class ShowMotesNpcSellPrice {
add("")
add("§6Total value: §d$price coins")
}
- add(Renderable.hoverTips("§6${stack.displayName}: §b$price", tips, indexes = index, stack = stack))
+ add(Renderable.hoverTips("§6${stack.displayName}: §b$price", tips, highlightsOnHoverSlots = index, stack = stack))
})
}
val total = itemMap.values.fold(0.0) { acc, pair -> acc + pair.second }.formatPrice()