aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenComposterInventoryFeatures.kt82
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBLockLevelGuideHelper.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt1
7 files changed, 139 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 1fcd4eb68..f8db6d0e6 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -237,6 +237,7 @@ public class SkyHanniMod {
loadModule(new GardenTeleportPadCompactName());
loadModule(new AnitaMedalProfit());
loadModule(new ComposterDisplay());
+ loadModule(new GardenComposterInventoryFeatures());
Commands.INSTANCE.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
index 1a46c3785..f6879a86d 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -164,6 +164,12 @@ public class Garden {
public boolean numberCropUpgrades = true;
@Expose
+ @ConfigOption(name = "Composter Upgrades", desc = "Show the number of upgrades in the composter upgrades inventory.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 5)
+ public boolean numberComposterUpgrades = true;
+
+ @Expose
@ConfigOption(name = "Crop Milestones", desc = "")
@ConfigEditorAccordion(id = 6)
public boolean cropMilestones = false;
@@ -686,6 +692,24 @@ public class Garden {
public boolean composterDisplayEnabled = true;
@Expose
+ @ConfigOption(
+ name = "Upgrade Price",
+ desc = "Show the price for the composter upgrade in the lore."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 17)
+ public boolean composterUpgradePrice = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Highlight Upgrade",
+ desc = "Highlight Upgrades that can be bought right now."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 17)
+ public boolean composterHighLightUpgrade = true;
+
+ @Expose
public Position composterDisplayPos = new Position(-363, 13, false, true);
@Expose
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
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index bbd420743..cf0192ca4 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -137,7 +137,8 @@ object ItemUtils {
fun isSkyBlockMenuItem(stack: ItemStack?): Boolean = stack?.getInternalName() == "SKYBLOCK_MENU"
- private val pattern = Pattern.compile("(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>[\\d,]+))?")
+ private val patternInFront = Pattern.compile("(?: *§8(?<amount>[\\d,]+)x )?(?<name>.*)")
+ private val patternBehind = Pattern.compile("(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>[\\d,]+))?")
private val itemAmountCache = mutableMapOf<String, Pair<String, Int>>()
@@ -145,10 +146,20 @@ object ItemUtils {
if (itemAmountCache.containsKey(input)) {
return itemAmountCache[input]!!
}
+
+ var matcher = patternInFront.matcher(input)
+ if (matcher.matches()) {
+ val itemName = matcher.group("name")
+ val amount = matcher.group("amount")?.replace(",", "")?.toInt() ?: 1
+ val pair = Pair(itemName, amount)
+ itemAmountCache[input] = pair
+ return pair
+ }
+
var string = input.trim()
val color = string.substring(0, 2)
string = string.substring(2)
- val matcher = pattern.matcher(string)
+ matcher = patternBehind.matcher(string)
if (!matcher.matches()) return Pair(null, 0)
val itemName = color + matcher.group("name").trim()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 8e9b9de9e..921229e05 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -62,6 +62,7 @@ object LorenzUtils {
}
fun error(message: String) {
+ println("error: '$message'")
internalChat("§c$message")
}