diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-02 12:55:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 12:55:52 +0200 |
commit | 0b3495878211a456d3cd8773ee09cab1c65aa2a3 (patch) | |
tree | e0b04693956338904581f8c3336179ad1af1d876 | |
parent | 51cc5a1516c1c31589de1018f194068277219998 (diff) | |
download | skyhanni-0b3495878211a456d3cd8773ee09cab1c65aa2a3.tar.gz skyhanni-0b3495878211a456d3cd8773ee09cab1c65aa2a3.tar.bz2 skyhanni-0b3495878211a456d3cd8773ee09cab1c65aa2a3.zip |
Improvement: Updating Chocolate Shop (#1652)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
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( |