diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
2 files changed, 24 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt index 8a34cccb3..2c7c056ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt @@ -20,7 +20,7 @@ enum class ChocolateAmount(val chocolate: () -> Long) { return when { time.isInfinite() -> "§cNever" time.isNegative() -> "§aNow" - else -> "§6${time.format()}" + else -> "§b${time.format()}" } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt index bc3528b99..a0b87a27c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -14,6 +15,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.million import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.renderables.Renderable +import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object ChocolateShopPrice { @@ -27,18 +29,31 @@ object ChocolateShopPrice { ) var inInventory = false + var inventoryItems = emptyMap<Int, ItemStack>() + + @SubscribeEvent + fun onSecondPassed(event: SecondPassedEvent) { + if (inInventory) { + update() + } + } @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!isEnabled()) return if (!menuNamePattern.matches(event.inventoryName)) return - val multiplier = 1.million - inInventory = true + inventoryItems = event.inventoryItems + update() + } + + private fun update() { + val multiplier = 1.million // TODO merge core with SkyMartCopperPrice into a utils val table = mutableListOf<DisplayTableEntry>() - for ((slot, item) in event.inventoryItems) { + val inventoryItems = inventoryItems + for ((slot, item) in inventoryItems) { val lore = item.getLore() val chocolate = ChocolateFactoryAPI.getChocolateBuyCost(lore) ?: continue val internalName = item.getInternalName() @@ -57,6 +72,11 @@ object ChocolateShopPrice { add("") add("§7Profit per million chocolate: §6${perFormat} ") + + add("") + val formattedTimeUntilGoal = ChocolateAmount.CURRENT.formattedTimeUntilGoal(chocolate) + add("§7Time until affordable: §6$formattedTimeUntilGoal ") + } table.add( DisplayTableEntry( |