diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-11 00:51:30 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-11 00:51:30 +0200 |
commit | 65d8a310f7880d1acfe799dbc0c90cc9cef08610 (patch) | |
tree | dcd46d7470e9cf730a9300ade19bf04976274728 /src/main | |
parent | 495f8ede53fd8a65b3c28d32282b0264e349a10c (diff) | |
download | skyhanni-65d8a310f7880d1acfe799dbc0c90cc9cef08610.tar.gz skyhanni-65d8a310f7880d1acfe799dbc0c90cc9cef08610.tar.bz2 skyhanni-65d8a310f7880d1acfe799dbc0c90cc9cef08610.zip |
Added Composter Inventory Numbers - Show the amount of Organic Matter, Fuel and Composts Available while inside the composter inventory.
Diffstat (limited to 'src/main')
3 files changed, 83 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 61f4315d2..e5169ab86 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -25,6 +25,7 @@ import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder; import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow; import at.hannibal2.skyhanni.features.fishing.*; import at.hannibal2.skyhanni.features.garden.*; +import at.hannibal2.skyhanni.features.garden.composter.ComposterInventoryNumbers; import at.hannibal2.skyhanni.features.inventory.*; import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles; import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown; @@ -242,6 +243,7 @@ public class SkyHanniMod { loadModule(new MinionCollectLogic()); loadModule(new PasteIntoSigns()); loadModule(new EstimatedItemValue()); + loadModule(new ComposterInventoryNumbers()); 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 d433d401e..336e83755 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -749,6 +749,15 @@ public class Garden { public Position composterDisplayPos = new Position(-363, 13, false, true); @Expose + @ConfigOption( + name = "Inventory Numbers", + desc = "Show the amount of Organic Matter, Fuel and Composts Available while inside the composter inventory." + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 17) + public boolean composterInventoryNumbers = true; + + @Expose @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") @ConfigEditorBoolean public boolean plotPrice = true; diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt new file mode 100644 index 000000000..51e30ef16 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt @@ -0,0 +1,72 @@ +package at.hannibal2.skyhanni.features.garden.composter + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Pattern + +class ComposterInventoryNumbers { + private val valuePattern = Pattern.compile("(?:.*) §e(.*)§6\\/(.*)") + private val compostsPattern = Pattern.compile("§7§7Compost Available: §a(.*)") + + @SubscribeEvent + fun onRenderItemTip(event: RenderInventoryItemTipEvent) { + if (!GardenAPI.inGarden()) return + if (!SkyHanniMod.feature.garden.composterInventoryNumbers) return + + if (event.inventoryName != "Composter") return + + val stack = event.stack + + val slotNumber = event.slot.slotNumber + + // Composts Available + if (slotNumber == 22) { + for (line in stack.getLore()) { + val matcher = compostsPattern.matcher(line) + if (!matcher.matches()) continue + + val total = matcher.group(1).replace(",", "").toInt() + if (total <= 64) continue + + event.offsetY = -2 + event.offsetX = -20 + event.stackTip = "§6$total" + return + } + } + + // Organic Matter or Fuel + if (slotNumber == 46 || slotNumber == 52) { + for (line in stack.getLore()) { + val matcher = valuePattern.matcher(line) + if (!matcher.matches()) continue + + val having = matcher.group(1).removeColor().replace(",", "").toDouble().toInt() + val havingFormat = NumberUtil.format(having) + val total = matcher.group(2).removeColor() + + + val color = if (slotNumber == 46) { + // Organic Matter + event.offsetY = -95 + event.offsetX = 5 + event.alignLeft = false + "§e" + } else { + // Fuel + event.offsetY = -76 + event.offsetX = -20 + "§a" + } + + event.stackTip = "$color$havingFormat/$total" + return + } + } + } +}
\ No newline at end of file |