diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-31 20:08:47 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-31 20:08:47 +0200 |
| commit | 58eccf5c7bf37c6279e15cd9e107b1fafd6e4509 (patch) | |
| tree | ef98c7cfcc0ef2032a635393eda2a3c0a39a87be /src/main/java/at/hannibal2/skyhanni/features | |
| parent | 33c7a5c0a13e98af7895aeb7eaf3109a3c841a5f (diff) | |
| download | skyhanni-58eccf5c7bf37c6279e15cd9e107b1fafd6e4509.tar.gz skyhanni-58eccf5c7bf37c6279e15cd9e107b1fafd6e4509.tar.bz2 skyhanni-58eccf5c7bf37c6279e15cd9e107b1fafd6e4509.zip | |
Added Composter Upgrade Price - Show the price for the composter upgrade in the lore
Added Highlight Upgrade - Highlight Upgrades that can be bought right now.
Added Number Composter Upgrades - Show the number of upgrades in the composter upgrades inventory.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
3 files changed, 100 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenComposterInventoryFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenComposterInventoryFeatures.kt new file mode 100644 index 000000000..a14d5ac39 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenComposterInventoryFeatures.kt @@ -0,0 +1,82 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.ContainerChest +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class GardenComposterInventoryFeatures { + val config get() = SkyHanniMod.feature.garden + + @SubscribeEvent + fun onTooltip(event: ItemTooltipEvent) { + if (!GardenAPI.inGarden()) return + if (!config.composterUpgradePrice) return + + if (InventoryUtils.openInventoryName() != "Composter Upgrades") return + + var next = false + val list = event.toolTip + var i = -1 + var indexFullCost = 0 + var fullPrice = 0.0 + var amountItems = 0 + for (originalLine in list) { + i++ + val line = originalLine.substring(4) + if (line == "§7Upgrade Cost:") { + next = true + indexFullCost = i + continue + } + + if (next) { + if (line.endsWith(" Copper")) continue + if (line == "") break + val (itemName, amount) = ItemUtils.readItemAmount(line) + if (itemName == null) { + LorenzUtils.error("§c[SkyHanni] Could not read item '$line'") + continue + } + val lowestBin = NEUItems.getPrice(NEUItems.getInternalName(itemName)) + val price = lowestBin * amount + fullPrice += price + val format = NumberUtil.format(price) + list[i] = list[i] + " §7(§6$format§7)" + amountItems++ + } + } + + if (amountItems > 1) { + val format = NumberUtil.format(fullPrice) + list[indexFullCost] = list[indexFullCost] + " §7(§6$format§7)" + } + } + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.composterHighLightUpgrade) return + + if (InventoryUtils.openInventoryName() == "Composter Upgrades") { + if (event.gui !is GuiChest) return + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + + for (slot in chest.inventorySlots) { + if (slot == null) continue + if (slot.slotNumber != slot.slotIndex) continue + val stack = slot.stack ?: continue + + if (stack.getLore().any { it == "§eClick to upgrade!" }) { + slot highlight LorenzColor.GOLD + } + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt index 6655fdf10..76770e182 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern @@ -12,6 +13,8 @@ class GardenInventoryNumbers { private var patternTierProgress = Pattern.compile("§7Progress to Tier (.*): §e(?:.*)") private var patternUpgradeTier = Pattern.compile("§7Current Tier: §e(.*)§7/§a.*") + private val patternComposterUpgrades = + Pattern.compile("§a(?:Composter Speed|Multi Drop|Fuel Cap|Organic Matter Cap|Cost Reduction) ?(.*)?") @SubscribeEvent fun onRenderItemTip(event: RenderItemTipEvent) { @@ -23,7 +26,6 @@ class GardenInventoryNumbers { event.stack.getLore() .map { patternTierProgress.matcher(it) } .filter { it.matches() } - .map { it.group(1).romanToDecimalIfNeeded() - 1 } .forEach { event.stackTip = "" + it } } @@ -37,5 +39,19 @@ class GardenInventoryNumbers { .map { it.group(1) } .forEach { event.stackTip = "" + it } } + + if (InventoryUtils.openInventoryName() == "Composter Upgrades") { + if (!SkyHanniMod.feature.garden.numberComposterUpgrades) return + + event.stack.name?.let { + val matcher = patternComposterUpgrades.matcher(it) + if (matcher.matches()) { + event.stackTip = if (matcher.groupCount() != 0) { + val group = matcher.group(1) + "" + group.romanToDecimalIfNeeded() + } else "0" + } + } + } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBLockLevelGuideHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBLockLevelGuideHelper.kt index 634aa5758..063f17612 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBLockLevelGuideHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBLockLevelGuideHelper.kt @@ -29,9 +29,7 @@ class SkyBLockLevelGuideHelper { if (slot.slotNumber != slot.slotIndex) continue val name = slot.stack?.name ?: continue - if (name.startsWith("§a✔")) { -// slot highlight LorenzColor.GREEN - } else if (name.startsWith("§c✖")) { + if (name.startsWith("§c✖")) { slot highlight LorenzColor.RED } } |
