From b9a505e162ee86b9e6afcc98ba5bb2a1c5ea3656 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 07:58:38 +0200 Subject: [PATCH 01/21] Added fossil excavator and research center to hide non clickable items feature. --- .../inventory/HideNotClickableItems.kt | 77 +++++++++++++++---- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index 117dcf8e4960..a5fa5e44a84d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -18,9 +18,12 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.InventoryUtils.getLowerItems +import at.hannibal2.skyhanni.utils.ItemCategory import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull +import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted import at.hannibal2.skyhanni.utils.ItemUtils.isVanilla @@ -48,7 +51,7 @@ class HideNotClickableItems { private val config get() = SkyHanniMod.feature.inventory.hideNotClickable private var hideReason = "" - private var reverseColor = false + private var showGreenLine = false private var lastClickTime = 0L private var bypassUntil = 0L @@ -103,7 +106,7 @@ class HideNotClickableItems { val opacity = config.opacity val color = LorenzColor.DARK_GRAY.addOpacity(opacity) stack.background = color.rgb - } else if (reverseColor && config.itemsGreenLine) { + } else if (showGreenLine && config.itemsGreenLine) { val color = LorenzColor.GREEN.addOpacity(200) stack.borderLine = color.rgb } @@ -176,7 +179,7 @@ class HideNotClickableItems { private fun hide(chestName: String, stack: ItemStack): Boolean { hideReason = "" - reverseColor = false + showGreenLine = false return when { hideNpcSell(stack) -> true @@ -197,16 +200,60 @@ class HideNotClickableItems { hideComposter(chestName, stack) -> true hideRiftMotesGrubber(chestName, stack) -> true hideRiftTransferChest(chestName, stack) -> true + hideFossilExcavator(chestName, stack) -> true + hideResearchCenter(chestName, stack) -> true else -> { false } } } + private fun hideFossilExcavator(chestName: String, stack: ItemStack): Boolean { + if (chestName != "Fossil Excavator") return false + + showGreenLine = true + + val internalName = stack.getInternalNameOrNull() ?: return true + if (internalName == "SUSPICIOUS_SCRAP".asInternalName()) { + return false + } + + val category = stack.getItemCategoryOrNull() ?: return true + if (category == ItemCategory.CHISEL) { + return false + } + + hideReason = "§cNo chisel or scrap!" + return true + } + + private fun hideResearchCenter(chestName: String, stack: ItemStack): Boolean { + if (chestName != "Research Center") return false + + showGreenLine = true + + val internalName = stack.getInternalNameOrNull() ?: return false + + // TODO add more special named fossils (hypixel why) + val list = listOf( + "HELIX".asInternalName(), + ) + + if (internalName in list) { + return false + } + if (internalName.endsWith("_FOSSIL")) { + return false + } + + hideReason = "§cNo fossil!" + return true + } + private fun hideRiftTransferChest(chestName: String, stack: ItemStack): Boolean { if (chestName != "Rift Transfer Chest") return false - reverseColor = true + showGreenLine = true val riftTransferable = stack.isRiftTransferable() ?: return true if (riftTransferable) { return false @@ -226,7 +273,7 @@ class HideNotClickableItems { if (!RiftAPI.inRift()) return false if (chestName != "Motes Grubber") return false - reverseColor = true + showGreenLine = true if (stack.motesNpcPrice() != null) return false @@ -237,7 +284,7 @@ class HideNotClickableItems { private fun hideComposter(chestName: String, stack: ItemStack): Boolean { if (!ComposterOverlay.inInventory) return false - reverseColor = true + showGreenLine = true val internalName = stack.getInternalName() if (internalName == ComposterOverlay.currentOrganicMatterItem) { @@ -268,7 +315,7 @@ class HideNotClickableItems { ) for (type in list) { if (stack.getLore().any { it.contains("§l") && it.contains(type) }) {// todo use item api - reverseColor = true + showGreenLine = true return false } } @@ -285,7 +332,7 @@ class HideNotClickableItems { private fun hideAttributeFusion(chestName: String, stack: ItemStack): Boolean { if (!chestName.startsWith("Attribute Fusion")) return false - reverseColor = true + showGreenLine = true if (ItemUtils.hasAttributes(stack)) return false @@ -312,7 +359,7 @@ class HideNotClickableItems { return true } - reverseColor = true + showGreenLine = true if (stack.cleanName().endsWith(" Potion") || stack.cleanName() == "Water Bottle") return false hideReason = "This item is not a potion!" @@ -327,7 +374,7 @@ class HideNotClickableItems { return true } - reverseColor = true + showGreenLine = true if (stack.getLore().any { it.removeColor() == "Fishing Bait" }) { return false } @@ -340,7 +387,7 @@ class HideNotClickableItems { if (ItemUtils.isSkyBlockMenuItem(stack)) return false val name = stack.cleanName() - reverseColor = true + showGreenLine = true if (ItemUtils.isSack(stack)) return false @@ -352,7 +399,7 @@ class HideNotClickableItems { if (!chestName.startsWith("Accessory Bag") && !chestName.startsWith("Accessory Bag (")) return false if (ItemUtils.isSkyBlockMenuItem(stack)) return false - reverseColor = true + showGreenLine = true if (stack.getLore().any { it.contains("ACCESSORY") || it.contains("HATCESSORY") }) return false hideReason = "This item is not an accessory!" @@ -432,7 +479,7 @@ class HideNotClickableItems { private fun hideNpcSell(stack: ItemStack): Boolean { if (!ShiftClickNPCSell.inInventory) return false if (VisitorAPI.inInventory) return false - reverseColor = true + showGreenLine = true var name = stack.cleanName() val size = stack.stackSize @@ -480,7 +527,7 @@ class HideNotClickableItems { private fun hideSalvage(chestName: String, stack: ItemStack): Boolean { if (!chestName.equalsOneOf("Salvage Item", "Salvage Items")) return false - reverseColor = true + showGreenLine = true if (ItemUtils.isRecombobulated(stack)) { hideReason = "This item should not be salvaged! (Recombobulated)" @@ -521,7 +568,7 @@ class HideNotClickableItems { val auctionHouseInventory = chestName == "Co-op Auction House" || chestName == "Auction House" || chestName == "Create BIN Auction" || chestName == "Create Auction" if (!bazaarInventory && !auctionHouseInventory) return false - reverseColor = true + showGreenLine = true if (ItemUtils.isSkyBlockMenuItem(stack)) { if (bazaarInventory) hideReason = "The SkyBlock Menu is not a Bazaar Product!" From d236f22f9f9fa86f5e2e6132b11395e7d2629bec Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 08:21:51 +0200 Subject: [PATCH 02/21] create a fossil excavator api --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 +- .../fossilexcavator/FossilExcavatorAPI.kt | 38 +++++++++++++++++++ .../FossilExcavatorProfitTracker.kt | 4 ++ .../{ => solver}/FossilExcavator.kt | 34 +++++------------ .../{ => solver}/FossilExcavatorSolver.kt | 2 +- .../{ => solver}/FossilMutation.kt | 2 +- .../{ => solver}/FossilShape.kt | 2 +- .../{ => solver}/FossilTile.kt | 2 +- .../{ => solver}/FossilType.kt | 2 +- 9 files changed, 59 insertions(+), 31 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt rename src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/{ => solver}/FossilExcavator.kt (87%) rename src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/{ => solver}/FossilExcavatorSolver.kt (98%) rename src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/{ => solver}/FossilMutation.kt (91%) rename src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/{ => solver}/FossilShape.kt (92%) rename src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/{ => solver}/FossilTile.kt (69%) rename src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/{ => solver}/FossilType.kt (98%) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index bb1e05cfc125..622d8adfa4e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -268,7 +268,8 @@ import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsNamesI import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsWalls import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventDisplay import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventTracker -import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavator +import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorAPI +import at.hannibal2.skyhanni.features.mining.fossilexcavator.solver.FossilExcavator import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker import at.hannibal2.skyhanni.features.minion.InfernoMinionFeatures import at.hannibal2.skyhanni.features.minion.MinionCollectLogic @@ -536,6 +537,7 @@ class SkyHanniMod { loadModule(LorenzUtils) loadModule(NEUItems) loadModule(PestAPI) + loadModule(FossilExcavatorAPI) // features loadModule(BazaarOrderHelper()) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt new file mode 100644 index 000000000000..ad053115b7c1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -0,0 +1,38 @@ +package at.hannibal2.skyhanni.features.mining.fossilexcavator + +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object FossilExcavatorAPI { + + var inInventory = false + var inExcavatorMenu = false + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (!IslandType.DWARVEN_MINES.isInIsland()) return + if (event.inventoryName != "Fossil Excavator") return + inInventory = true + val slots = InventoryUtils.getItemsInOpenChest() + val itemNames = slots.map { it.stack.displayName.removeColor() } + inExcavatorMenu = itemNames.any { it == "Start Excavator" } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + inInventory = false + inExcavatorMenu = false + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + inInventory = false + inExcavatorMenu = false + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt new file mode 100644 index 000000000000..57e9f00b9781 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt @@ -0,0 +1,4 @@ +package at.hannibal2.skyhanni.features.mining.fossilexcavator + +class FossilExcavatorProfitTracker { +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavator.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavator.kt similarity index 87% rename from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavator.kt rename to src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavator.kt index e1c46e12ef51..078e96d54e23 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavator.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mining.fossilexcavator +package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.SkyHanniMod.Companion.coroutineScope @@ -6,10 +6,10 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent +import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorAPI import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor @@ -38,8 +38,7 @@ object FossilExcavator { "Fossil Excavation Progress: (?[\\d.]+%)" ) - private var inInventory = false - private var inExcavatorMenu = false + private val inExcavatorMenu get() = FossilExcavatorAPI.inExcavatorMenu private var foundPercentage = false private var percentage: String? = null @@ -63,13 +62,6 @@ object FossilExcavator { var possibleFossilTypes = setOf() - @SubscribeEvent - fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!isEnabled()) return - if (event.inventoryName != "Fossil Excavator") return - inInventory = true - } - @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { clearData() @@ -81,8 +73,6 @@ object FossilExcavator { } private fun clearData() { - inInventory = false - inExcavatorMenu = false foundPercentage = false percentage = null chargesRemaining = 0 @@ -97,12 +87,10 @@ object FossilExcavator { @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (!inInventory) return val slots = InventoryUtils.getItemsInOpenChest() val itemNames = slots.map { it.stack.displayName.removeColor() } if (itemNames != inventoryItemNames) { inventoryItemNames = itemNames - inExcavatorMenu = itemNames.any { it == "Start Excavator" } if (inExcavatorMenu) return updateData() @@ -153,7 +141,6 @@ object FossilExcavator { @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { if (!isEnabled()) return - if (!inInventory) return if (inExcavatorMenu) return event.makePickblock() @@ -168,7 +155,6 @@ object FossilExcavator { @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { if (!isEnabled()) return - if (!inInventory) return if (inExcavatorMenu) return if (slotToClick == null) return @@ -182,7 +168,6 @@ object FossilExcavator { @SubscribeEvent fun onRenderItemTip(event: RenderInventoryItemTipEvent) { if (!isEnabled()) return - if (!inInventory) return if (!config.showPercentage) return if (slotToClick != event.slot.slotNumber) return if (inExcavatorMenu) return @@ -196,7 +181,6 @@ object FossilExcavator { @SubscribeEvent fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { if (!isEnabled()) return - if (!inInventory) return if (inExcavatorMenu) { // render here so they can move it around. As if you press key while doing the excavator you lose the scrap @@ -209,9 +193,9 @@ object FossilExcavator { when { isNotPossible -> displayList.add(NOT_POSSIBLE_STRING) isCompleted -> displayList.add(SOLVED_STRING) - else -> displayList.add("$FOSSILS_REMAINING_STRING§a$possibleFossilsRemaining") + else -> displayList.add("${FOSSILS_REMAINING_STRING}§a$possibleFossilsRemaining") } - displayList.add("$CHARGES_REMAINING_STRING§a$chargesRemaining") + displayList.add("${CHARGES_REMAINING_STRING}§a$chargesRemaining") if (possibleFossilTypes.isNotEmpty()) { displayList.add("§ePossible Fossil types:") @@ -226,9 +210,9 @@ object FossilExcavator { fun nextData(slotToClick: FossilTile, correctPercentage: Double, fossilsRemaining: Int) { val formattedPercentage = (correctPercentage * 100).round(1) - this.possibleFossilsRemaining = fossilsRemaining - this.slotToClick = slotToClick.toSlotIndex() - this.correctPercentage = "§2$formattedPercentage%" + possibleFossilsRemaining = fossilsRemaining + FossilExcavator.slotToClick = slotToClick.toSlotIndex() + FossilExcavator.correctPercentage = "§2$formattedPercentage%" } fun showError() { @@ -239,5 +223,5 @@ object FossilExcavator { isCompleted = true } - private fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enabled + private fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enabled && FossilExcavatorAPI.inInventory } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavatorSolver.kt similarity index 98% rename from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorSolver.kt rename to src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavatorSolver.kt index b12e336742af..18c256529c00 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorSolver.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavatorSolver.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mining.fossilexcavator +package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver object FossilExcavatorSolver { /* diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilMutation.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilMutation.kt similarity index 91% rename from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilMutation.kt rename to src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilMutation.kt index f039b2ef096e..724e2a5aadd9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilMutation.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilMutation.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mining.fossilexcavator +package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver enum class FossilMutation(val modification: (FossilShape) -> FossilShape) { ROTATE_0({ positions -> positions.rotate(0) }), diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilShape.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilShape.kt similarity index 92% rename from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilShape.kt rename to src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilShape.kt index c30bb91755a3..ae8b25593d44 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilShape.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilShape.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mining.fossilexcavator +package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver data class FossilShape(val tiles: List) { fun width() = tiles.maxOf { it.x } - tiles.minOf { it.x } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilTile.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilTile.kt similarity index 69% rename from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilTile.kt rename to src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilTile.kt index 1c6ba70702c5..e671633cbe05 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilTile.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilTile.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mining.fossilexcavator +package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver data class FossilTile(val x: Int, val y: Int) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilType.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilType.kt similarity index 98% rename from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilType.kt rename to src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilType.kt index 208dfac96404..e97271dfbe17 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilType.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mining.fossilexcavator +package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver enum class FossilType( val displayName: String, From 83980b8491c2d410862eb117ae43eb0befe98b05 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 08:35:07 +0200 Subject: [PATCH 03/21] fix inExcavatorMenu --- .../features/mining/fossilexcavator/FossilExcavatorAPI.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt index ad053115b7c1..bb9e2c30b00d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.mining.fossilexcavator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -19,6 +20,11 @@ object FossilExcavatorAPI { if (!IslandType.DWARVEN_MINES.isInIsland()) return if (event.inventoryName != "Fossil Excavator") return inInventory = true + } + + @SubscribeEvent + fun onInventoryUpdated(event: InventoryUpdatedEvent) { + if (!inInventory) return val slots = InventoryUtils.getItemsInOpenChest() val itemNames = slots.map { it.stack.displayName.removeColor() } inExcavatorMenu = itemNames.any { it == "Start Excavator" } From 0f0c640de1fffd18faabcf5946445b2f82304fac Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 08:35:57 +0200 Subject: [PATCH 04/21] using FossilExcavatorAPI --- .../features/inventory/HideNotClickableItems.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index a5fa5e44a84d..977e8b426da1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi +import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorAPI import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.features.rift.RiftAPI.motesNpcPrice import at.hannibal2.skyhanni.utils.ChatUtils @@ -200,16 +201,15 @@ class HideNotClickableItems { hideComposter(chestName, stack) -> true hideRiftMotesGrubber(chestName, stack) -> true hideRiftTransferChest(chestName, stack) -> true - hideFossilExcavator(chestName, stack) -> true + hideFossilExcavator(stack) -> true hideResearchCenter(chestName, stack) -> true - else -> { - false - } + + else -> false } } - private fun hideFossilExcavator(chestName: String, stack: ItemStack): Boolean { - if (chestName != "Fossil Excavator") return false + private fun hideFossilExcavator(stack: ItemStack): Boolean { + if (!FossilExcavatorAPI.inExcavatorMenu) return false showGreenLine = true From d369bfbda102072f1a6be6533f3616718efc3843 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 12 Apr 2024 08:38:11 +0200 Subject: [PATCH 05/21] Delete FossilExcavatorProfitTracker.kt --- .../mining/fossilexcavator/FossilExcavatorProfitTracker.kt | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt deleted file mode 100644 index 57e9f00b9781..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt +++ /dev/null @@ -1,4 +0,0 @@ -package at.hannibal2.skyhanni.features.mining.fossilexcavator - -class FossilExcavatorProfitTracker { -} From 915ec590504f506ae58334c49689469703f04952 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 10:26:55 +0200 Subject: [PATCH 06/21] init --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 6 +- .../FossilExcavatorProfitTracker.kt | 67 +++++++++++++++++++ ...ssilExcavatorSolver.kt => FossilSolver.kt} | 16 ++--- ...silExcavator.kt => FossilSolverDisplay.kt} | 12 ++-- .../at/hannibal2/skyhanni/utils/ItemUtils.kt | 3 - 5 files changed, 85 insertions(+), 19 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt rename src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/{FossilExcavatorSolver.kt => FossilSolver.kt} (90%) rename src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/{FossilExcavator.kt => FossilSolverDisplay.kt} (96%) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 622d8adfa4e9..c1db52d68315 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -269,7 +269,8 @@ import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsWalls import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventDisplay import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventTracker import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorAPI -import at.hannibal2.skyhanni.features.mining.fossilexcavator.solver.FossilExcavator +import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorProfitTracker +import at.hannibal2.skyhanni.features.mining.fossilexcavator.solver.FossilSolverDisplay import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker import at.hannibal2.skyhanni.features.minion.InfernoMinionFeatures import at.hannibal2.skyhanni.features.minion.MinionCollectLogic @@ -661,7 +662,8 @@ class SkyHanniMod { loadModule(GardenCropMilestoneDisplay) loadModule(GardenCustomKeybinds) loadModule(ChickenHeadTimer()) - loadModule(FossilExcavator) + loadModule(FossilSolverDisplay) + loadModule(FossilExcavatorProfitTracker()) loadModule(GardenOptimalSpeed()) loadModule(GardenLevelDisplay()) loadModule(FarmingWeightDisplay()) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt new file mode 100644 index 000000000000..4ae2ea5faba9 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt @@ -0,0 +1,67 @@ +package at.hannibal2.skyhanni.features.mining.fossilexcavator + +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.ItemUtils +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.PrimitiveItemStack +import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class FossilExcavatorProfitTracker { + + private val patternGroup = RepoPattern.group("mining.fossil.excavator") + private val chatPatternGroup = patternGroup.group("chat") + + /** + * REGEX-TEST: §r§6§lEXCAVATION COMPLETE + */ + private val startPattern by chatPatternGroup.pattern("start", " {2}§r§6§lEXCAVATION COMPLETE ") + + /** + * REGEX-TEST: §a§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ + */ + private val endPattern by chatPatternGroup.pattern("end", "§a§l▬{64}") + + /** + * REGEX-TEST: §r§6Tusk Fossil + */ + private val itemPattern by chatPatternGroup.pattern("item", " {4}§r(?.+)") + + private var inLoot = false + private var newItems = mutableListOf() + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + val message = event.message + + if (startPattern.matches(message)) { + inLoot = true + return + } + + if (!inLoot) return + + if (endPattern.matches(message)) { + inLoot = false + newExcavation() + return + } + + val (name, amount) = itemPattern.matchMatcher(message) { + val itemLine = group("item") + val newLine = itemLine.replace("§r", "") + ItemUtils.readItemAmount(newLine) ?: return + } ?: return + val internalName = NEUInternalName.fromItemNameOrNull(name) ?: return + val itemStack = internalName.makePrimitiveStack(amount) + println("itemStack: '$itemStack'") + newItems.add(itemStack) + } + + private fun newExcavation() { + + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavatorSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolver.kt similarity index 90% rename from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavatorSolver.kt rename to src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolver.kt index 18c256529c00..7af22d701fc8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavatorSolver.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolver.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver -object FossilExcavatorSolver { +object FossilSolver { /* to be used when they have less than 18 clicks - solves 361/404 in at most 16 clicks @@ -34,7 +34,7 @@ object FossilExcavatorSolver { private var currentlySolving = false private fun getCurrentSequence(): Set> { - return if (FossilExcavator.maxCharges < 18) { + return if (FossilSolverDisplay.maxCharges < 18) { riskyStartingSequence } else { safeStartingSequence @@ -62,13 +62,13 @@ object FossilExcavatorSolver { if (needsMoveSequence) { val movesTaken = invalidPositions.size if (movesTaken >= getCurrentSequence().size) { - FossilExcavator.showError() + FossilSolverDisplay.showError() currentlySolving = false return } val nextMove = getCurrentSequence().elementAt(movesTaken) - FossilExcavator.nextData(nextMove.first, nextMove.second, nextMove.third) + FossilSolverDisplay.nextData(nextMove.first, nextMove.second, nextMove.third) currentlySolving = false return } @@ -78,7 +78,7 @@ object FossilExcavatorSolver { val possibleFossilTypes = if (percentage == null) FossilType.entries else { val possibleFossils = FossilType.getByPercentage(percentage) - FossilExcavator.possibleFossilTypes = possibleFossils.toSet() + FossilSolverDisplay.possibleFossilTypes = possibleFossils.toSet() possibleFossils } @@ -106,12 +106,12 @@ object FossilExcavatorSolver { val bestPosition = possibleClickPositions.maxByOrNull { it.value } ?: run { if (fossilLocations.isNotEmpty()) { - FossilExcavator.showCompleted() + FossilSolverDisplay.showCompleted() currentlySolving = false return } - FossilExcavator.showError() + FossilSolverDisplay.showError() currentlySolving = false return } @@ -119,7 +119,7 @@ object FossilExcavatorSolver { val nextMove = bestPosition.key val correctPercentage = bestPosition.value / totalPossibleTiles currentlySolving = false - FossilExcavator.nextData(nextMove, correctPercentage, totalPossibleTiles.toInt()) + FossilSolverDisplay.nextData(nextMove, correctPercentage, totalPossibleTiles.toInt()) } private fun isValidFossilPosition( diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavator.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt similarity index 96% rename from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavator.kt rename to src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt index 078e96d54e23..3eccaf553302 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt @@ -24,7 +24,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import kotlinx.coroutines.launch import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -object FossilExcavator { +object FossilSolverDisplay { private val config get() = SkyHanniMod.feature.mining.fossilExcavator @@ -134,7 +134,7 @@ object FossilExcavator { } coroutineScope.launch { - FossilExcavatorSolver.findBestTile(fossilLocations, dirtLocations, percentage) + FossilSolver.findBestTile(fossilLocations, dirtLocations, percentage) } } @@ -184,7 +184,7 @@ object FossilExcavator { if (inExcavatorMenu) { // render here so they can move it around. As if you press key while doing the excavator you lose the scrap - config.position.renderString("§eExcavator solver gui", posLabel = "Fossil Excavator") + config.position.renderString("§eExcavator solver gui", posLabel = "Fossil Excavator Solver") return } @@ -204,15 +204,15 @@ object FossilExcavator { } } - config.position.renderStrings(displayList, posLabel = "Fossil Excavator") + config.position.renderStrings(displayList, posLabel = "Fossil Excavator Solver") } fun nextData(slotToClick: FossilTile, correctPercentage: Double, fossilsRemaining: Int) { val formattedPercentage = (correctPercentage * 100).round(1) possibleFossilsRemaining = fossilsRemaining - FossilExcavator.slotToClick = slotToClick.toSlotIndex() - FossilExcavator.correctPercentage = "§2$formattedPercentage%" + FossilSolverDisplay.slotToClick = slotToClick.toSlotIndex() + FossilSolverDisplay.correctPercentage = "§2$formattedPercentage%" } fun showError() { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 94558d9496a0..7f848b47fcb0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -313,9 +313,6 @@ object ItemUtils { string = string.substring(2) val matcher = UtilsPatterns.readAmountAfterPattern.matcher(string) if (!matcher.matches()) { - println("") - println("input: '$input'") - println("string: '$string'") return null } From 7778ad1e0ea6c5bff5989092b30cd549d059aebd Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 10:44:48 +0200 Subject: [PATCH 07/21] using FossilExcavationEvent --- .../events/mining/FossilExcavationEvent.kt | 5 ++ .../fossilexcavator/FossilExcavatorAPI.kt | 56 ++++++++++++++++ .../FossilExcavatorProfitTracker.kt | 64 +++---------------- 3 files changed, 70 insertions(+), 55 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/events/mining/FossilExcavationEvent.kt diff --git a/src/main/java/at/hannibal2/skyhanni/events/mining/FossilExcavationEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/mining/FossilExcavationEvent.kt new file mode 100644 index 000000000000..b672def95320 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/mining/FossilExcavationEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events.mining + +import at.hannibal2.skyhanni.events.LorenzEvent + +class FossilExcavationEvent(val loot: List>): LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt index bb9e2c30b00d..e45697a91675 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -4,14 +4,42 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent +import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object FossilExcavatorAPI { + private val patternGroup = RepoPattern.group("mining.fossil.excavator") + private val chatPatternGroup = patternGroup.group("chat") + + /** + * REGEX-TEST: §r§6§lEXCAVATION COMPLETE + */ + private val startPattern by chatPatternGroup.pattern("start", " {2}§r§6§lEXCAVATION COMPLETE ") + + /** + * REGEX-TEST: §a§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ + */ + private val endPattern by chatPatternGroup.pattern("end", "§a§l▬{64}") + + /** + * REGEX-TEST: §r§6Tusk Fossil + */ + private val itemPattern by chatPatternGroup.pattern("item", " {4}§r(?.+)") + + private var inLoot = false + private var loot = listOf>() + var inInventory = false var inExcavatorMenu = false @@ -41,4 +69,32 @@ object FossilExcavatorAPI { inInventory = false inExcavatorMenu = false } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + val message = event.message + + if (startPattern.matches(message)) { + inLoot = true + return + } + + if (!inLoot) return + + if (endPattern.matches(message)) { + FossilExcavationEvent(loot).postAndCatch() + loot = emptyList() + inLoot = false + return + } + + val pair = itemPattern.matchMatcher(message) { + val itemLine = group("item") + val newLine = itemLine.replace("§r", "") + ItemUtils.readItemAmount(newLine) ?: return + } ?: return + loot = loot.editCopy { + add(pair) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt index 4ae2ea5faba9..9628570760f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt @@ -1,67 +1,21 @@ package at.hannibal2.skyhanni.features.mining.fossilexcavator -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.utils.ItemUtils +import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.PrimitiveItemStack import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.StringUtils.matches -import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class FossilExcavatorProfitTracker { - private val patternGroup = RepoPattern.group("mining.fossil.excavator") - private val chatPatternGroup = patternGroup.group("chat") - - /** - * REGEX-TEST: §r§6§lEXCAVATION COMPLETE - */ - private val startPattern by chatPatternGroup.pattern("start", " {2}§r§6§lEXCAVATION COMPLETE ") - - /** - * REGEX-TEST: §a§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ - */ - private val endPattern by chatPatternGroup.pattern("end", "§a§l▬{64}") - - /** - * REGEX-TEST: §r§6Tusk Fossil - */ - private val itemPattern by chatPatternGroup.pattern("item", " {4}§r(?.+)") - - private var inLoot = false - private var newItems = mutableListOf() - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - val message = event.message - - if (startPattern.matches(message)) { - inLoot = true - return + fun onFossilExcavatrion(event: FossilExcavationEvent) { + for ((name, amount) in event.loot) { + println("") + println("name: '$name'") + println("amount: $amount") + val internalName = NEUInternalName.fromItemNameOrNull(name) ?: continue + val itemStack = internalName.makePrimitiveStack(amount) + println("itemStack: '$itemStack'") } - - if (!inLoot) return - - if (endPattern.matches(message)) { - inLoot = false - newExcavation() - return - } - - val (name, amount) = itemPattern.matchMatcher(message) { - val itemLine = group("item") - val newLine = itemLine.replace("§r", "") - ItemUtils.readItemAmount(newLine) ?: return - } ?: return - val internalName = NEUInternalName.fromItemNameOrNull(name) ?: return - val itemStack = internalName.makePrimitiveStack(amount) - println("itemStack: '$itemStack'") - newItems.add(itemStack) - } - - private fun newExcavation() { - } } From a97a355214175896228635bcb39a5688496a5706 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 11:24:20 +0200 Subject: [PATCH 08/21] added tracker --- .../mining/FossilExcavatorConfig.java | 24 ++---- .../FossilExcavatorProfitTrackerConfig.java | 32 ++++++++ .../mining/FossilExcavatorSolverConfig.java | 28 +++++++ .../storage/ProfileSpecificStorage.java | 6 +- .../fossilexcavator/FossilExcavatorAPI.kt | 13 ++- .../FossilExcavatorProfitTracker.kt | 80 ++++++++++++++++++- .../solver/FossilSolverDisplay.kt | 2 +- 7 files changed, 158 insertions(+), 27 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorProfitTrackerConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorSolverConfig.java diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java index d9a3ac7ba831..8a13d8208e0f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java @@ -1,29 +1,19 @@ package at.hannibal2.skyhanni.config.features.mining; -import at.hannibal2.skyhanni.config.FeatureToggle; -import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; -import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; +import io.github.notenoughupdates.moulconfig.annotations.Accordion; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; public class FossilExcavatorConfig { @Expose - @ConfigOption(name = "Fossil Excavator Helper", desc = "Helps you find fossils in the fossil excavator. " + - "§eWill always solve if you have at least 18 clicks. Solves everything except Spine, Ugly and Helix in 16 clicks.") - @ConfigEditorBoolean - @FeatureToggle - public boolean enabled = true; + @ConfigOption(name = "Fossil Excavator Solver", desc = "") + @Accordion + public FossilExcavatorSolverConfig solver = new FossilExcavatorSolverConfig(); @Expose - @ConfigOption(name = "Show Percentage", desc = "Shows percentage chance that next click will be a fossil. " + - "§eThis assumes there is a fossil hidden in the dirt.") - @ConfigEditorBoolean - public boolean showPercentage = true; - - @Expose - @ConfigLink(owner = FossilExcavatorConfig.class, field = "enabled") - public Position position = new Position(183, 212, false, true); + @ConfigOption(name = "Fossil Excavator Profit Tracker", desc = "") + @Accordion + public FossilExcavatorProfitTrackerConfig profitTracker = new FossilExcavatorProfitTrackerConfig(); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorProfitTrackerConfig.java new file mode 100644 index 000000000000..0917f0125bbe --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorProfitTrackerConfig.java @@ -0,0 +1,32 @@ +package at.hannibal2.skyhanni.config.features.mining; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +public class FossilExcavatorProfitTrackerConfig { + + @Expose + @ConfigOption( + name = "Enabled", + desc = "Count all drops you gain while excavating fossils in the Crystal Cave." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption( + name = "Show nearby", + desc = "Show the profit tracker while close to the excavation point." + ) + @ConfigEditorBoolean + public boolean showNearvy = true; + + @Expose + @ConfigLink(owner = FossilExcavatorProfitTrackerConfig.class, field = "enabled") + public Position position = new Position(20, 20, false, true); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorSolverConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorSolverConfig.java new file mode 100644 index 000000000000..94ce05f07f13 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorSolverConfig.java @@ -0,0 +1,28 @@ +package at.hannibal2.skyhanni.config.features.mining; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +public class FossilExcavatorSolverConfig { + + @Expose + @ConfigOption(name = "Fossil Excavator Helper", desc = "Helps you find fossils in the fossil excavator. " + + "§eWill always solve if you have at least 18 clicks. Solves everything except Spine, Ugly and Helix in 16 clicks.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Show Percentage", desc = "Shows percentage chance that next click will be a fossil. " + + "§eThis assumes there is a fossil hidden in the dirt.") + @ConfigEditorBoolean + public boolean showPercentage = true; + + @Expose + @ConfigLink(owner = FossilExcavatorSolverConfig.class, field = "enabled") + public Position position = new Position(-380, 150, false, true); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index 1a2d982234cb..ecfcfc023ca4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -20,9 +20,10 @@ import at.hannibal2.skyhanni.features.garden.farming.DicerRngDropTracker; import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLane; import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; -import at.hannibal2.skyhanni.features.garden.pests.VinylType; import at.hannibal2.skyhanni.features.garden.pests.PestProfitTracker; +import at.hannibal2.skyhanni.features.garden.pests.VinylType; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; +import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorProfitTracker; import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker; import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker; import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker; @@ -384,6 +385,9 @@ public static class MiningConfig { @Expose public List kingsTalkedTo = new ArrayList<>(); + + @Expose + public FossilExcavatorProfitTracker.Data fossilExcavatorProfitTracker = new FossilExcavatorProfitTracker.Data(); } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt index e45697a91675..7a95cdb3e368 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent -import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -38,7 +37,7 @@ object FossilExcavatorAPI { private val itemPattern by chatPatternGroup.pattern("item", " {4}§r(?.+)") private var inLoot = false - private var loot = listOf>() + private val loot = mutableListOf>() var inInventory = false var inExcavatorMenu = false @@ -72,6 +71,8 @@ object FossilExcavatorAPI { @SubscribeEvent fun onChat(event: LorenzChatEvent) { + if (!IslandType.DWARVEN_MINES.isInIsland()) return + val message = event.message if (startPattern.matches(message)) { @@ -82,8 +83,8 @@ object FossilExcavatorAPI { if (!inLoot) return if (endPattern.matches(message)) { - FossilExcavationEvent(loot).postAndCatch() - loot = emptyList() + FossilExcavationEvent(loot.toList()).postAndCatch() + loot.clear() inLoot = false return } @@ -93,8 +94,6 @@ object FossilExcavatorAPI { val newLine = itemLine.replace("§r", "") ItemUtils.readItemAmount(newLine) ?: return } ?: return - loot = loot.editCopy { - add(pair) - } + loot.add(pair) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt index 9628570760f5..d7341304caaf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt @@ -1,14 +1,76 @@ package at.hannibal2.skyhanni.features.mining.fossilexcavator +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack +import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData +import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker +import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class FossilExcavatorProfitTracker { + private val config get() = SkyHanniMod.feature.mining.fossilExcavator.profitTracker + + private val tracker = SkyHanniItemTracker( + "Fossil Excavation Profit Tracker", + { Data() }, + { it.mining.fossilExcavatorProfitTracker }) { drawDisplay(it) } + + class Data : ItemTrackerData() { + override fun resetItems() { + timesExcavated = 0 + } + + override fun getDescription(timesGained: Long): List { + val percentage = timesGained.toDouble() / timesExcavated + val dropRate = LorenzUtils.formatPercentage(percentage.coerceAtMost(1.0)) + return listOf( + "§7Dropped §e${timesGained.addSeparators()} §7times.", + "§7Your drop rate: §c$dropRate." + ) + } + + override fun getCoinName(item: TrackedItem) = "" + + override fun getCoinDescription(item: TrackedItem): List { + return listOf( + "" + ) + } + + @Expose + var timesExcavated = 0L + } + + private fun drawDisplay(data: Data): List> = buildList { + addAsSingletonList("§e§lFossil Excavation Profit Tracker") + val profit = tracker.drawItems(data, { true }, this) + + val pestsKilled = data.timesExcavated + addAsSingletonList( + Renderable.hoverTips( + "§7Times excavated: §e${pestsKilled.addSeparators()}", + listOf("§7You excavated §e${pestsKilled.addSeparators()} §7times.") + ) + ) + addAsSingletonList(tracker.addTotalProfit(profit, data.timesExcavated, "excarvation")) + + tracker.addPriceFromButton(this) + } + @SubscribeEvent - fun onFossilExcavatrion(event: FossilExcavationEvent) { + fun onFossilExcavation(event: FossilExcavationEvent) { + if (!isEnabled()) return for ((name, amount) in event.loot) { println("") println("name: '$name'") @@ -16,6 +78,22 @@ class FossilExcavatorProfitTracker { val internalName = NEUInternalName.fromItemNameOrNull(name) ?: continue val itemStack = internalName.makePrimitiveStack(amount) println("itemStack: '$itemStack'") + tracker.addItem(internalName, amount) + } + tracker.modify { + it.timesExcavated++ } } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent) { + if (!isEnabled()) return + if (GardenAPI.isCurrentlyFarming()) return + // TODO add distance check +// config.showNearvy + + tracker.renderDisplay(config.position) + } + + fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enabled } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt index 3eccaf553302..3b844d233084 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt @@ -26,7 +26,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object FossilSolverDisplay { - private val config get() = SkyHanniMod.feature.mining.fossilExcavator + private val config get() = SkyHanniMod.feature.mining.fossilExcavator.solver private val patternGroup = RepoPattern.group("mining.fossilexcavator") private val chargesRemainingPattern by patternGroup.pattern( From 311012387bf15a60c80731894b2e37e90597b031 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 11:38:35 +0200 Subject: [PATCH 09/21] added scrap cost --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 +- ...java => ExcavatorProfitTrackerConfig.java} | 4 +- .../mining/FossilExcavatorConfig.java | 4 +- .../storage/ProfileSpecificStorage.java | 4 +- ...itTracker.kt => ExcavatorProfitTracker.kt} | 40 ++++++++++++++++--- 5 files changed, 43 insertions(+), 13 deletions(-) rename src/main/java/at/hannibal2/skyhanni/config/features/mining/{FossilExcavatorProfitTrackerConfig.java => ExcavatorProfitTrackerConfig.java} (87%) rename src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/{FossilExcavatorProfitTracker.kt => ExcavatorProfitTracker.kt} (70%) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index c1db52d68315..5e69942c0c8b 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -268,8 +268,8 @@ import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsNamesI import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsWalls import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventDisplay import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventTracker +import at.hannibal2.skyhanni.features.mining.fossilexcavator.ExcavatorProfitTracker import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorAPI -import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorProfitTracker import at.hannibal2.skyhanni.features.mining.fossilexcavator.solver.FossilSolverDisplay import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker import at.hannibal2.skyhanni.features.minion.InfernoMinionFeatures @@ -663,7 +663,7 @@ class SkyHanniMod { loadModule(GardenCustomKeybinds) loadModule(ChickenHeadTimer()) loadModule(FossilSolverDisplay) - loadModule(FossilExcavatorProfitTracker()) + loadModule(ExcavatorProfitTracker()) loadModule(GardenOptimalSpeed()) loadModule(GardenLevelDisplay()) loadModule(FarmingWeightDisplay()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java similarity index 87% rename from src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorProfitTrackerConfig.java rename to src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java index 0917f0125bbe..ce16f9f10263 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorProfitTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java @@ -7,7 +7,7 @@ import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; -public class FossilExcavatorProfitTrackerConfig { +public class ExcavatorProfitTrackerConfig { @Expose @ConfigOption( @@ -27,6 +27,6 @@ public class FossilExcavatorProfitTrackerConfig { public boolean showNearvy = true; @Expose - @ConfigLink(owner = FossilExcavatorProfitTrackerConfig.class, field = "enabled") + @ConfigLink(owner = ExcavatorProfitTrackerConfig.class, field = "enabled") public Position position = new Position(20, 20, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java index 8a13d8208e0f..f1b70c6b3681 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java @@ -12,8 +12,8 @@ public class FossilExcavatorConfig { public FossilExcavatorSolverConfig solver = new FossilExcavatorSolverConfig(); @Expose - @ConfigOption(name = "Fossil Excavator Profit Tracker", desc = "") + @ConfigOption(name = "Excavator Profit Tracker", desc = "") @Accordion - public FossilExcavatorProfitTrackerConfig profitTracker = new FossilExcavatorProfitTrackerConfig(); + public ExcavatorProfitTrackerConfig profitTracker = new ExcavatorProfitTrackerConfig(); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index ecfcfc023ca4..bbf3f81cec99 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -23,7 +23,7 @@ import at.hannibal2.skyhanni.features.garden.pests.PestProfitTracker; import at.hannibal2.skyhanni.features.garden.pests.VinylType; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; -import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorProfitTracker; +import at.hannibal2.skyhanni.features.mining.fossilexcavator.ExcavatorProfitTracker; import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker; import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker; import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker; @@ -387,7 +387,7 @@ public static class MiningConfig { public List kingsTalkedTo = new ArrayList<>(); @Expose - public FossilExcavatorProfitTracker.Data fossilExcavatorProfitTracker = new FossilExcavatorProfitTracker.Data(); + public ExcavatorProfitTracker.Data fossilExcavatorProfitTracker = new ExcavatorProfitTracker.Data(); } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt similarity index 70% rename from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt rename to src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt index d7341304caaf..e5d405675520 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt @@ -3,12 +3,17 @@ package at.hannibal2.skyhanni.features.mining.fossilexcavator import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getPrice +import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -17,7 +22,7 @@ import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class FossilExcavatorProfitTracker { +class ExcavatorProfitTracker { private val config get() = SkyHanniMod.feature.mining.fossilExcavator.profitTracker @@ -52,17 +57,34 @@ class FossilExcavatorProfitTracker { var timesExcavated = 0L } + private val scrapItem = "SUSPICIOUS_SCRAP".asInternalName() + private fun drawDisplay(data: Data): List> = buildList { addAsSingletonList("§e§lFossil Excavation Profit Tracker") - val profit = tracker.drawItems(data, { true }, this) + var profit = tracker.drawItems(data, { true }, this) + + val timesExcavated = data.timesExcavated + addAsSingletonList( + Renderable.hoverTips( + "§7Times excavated: §e${timesExcavated.addSeparators()}", + listOf("§7You excavated §e${timesExcavated.addSeparators()} §7times.") + ) + ) - val pestsKilled = data.timesExcavated + // TODO use same price source as profit tracker + val scrapPrice = timesExcavated * scrapItem.getPrice() + profit -= scrapPrice addAsSingletonList( Renderable.hoverTips( - "§7Times excavated: §e${pestsKilled.addSeparators()}", - listOf("§7You excavated §e${pestsKilled.addSeparators()} §7times.") + "${scrapItem.itemName}§7: §c${NumberUtil.format(scrapPrice)}", + listOf( + "§7You paid ${NumberUtil.format(scrapPrice)} coins", + "§7in total for all §e$timesExcavated §7${scrapItem.itemName}", + "§7you have used." + ) ) ) + addAsSingletonList(tracker.addTotalProfit(profit, data.timesExcavated, "excarvation")) tracker.addPriceFromButton(this) @@ -93,6 +115,14 @@ class FossilExcavatorProfitTracker { // config.showNearvy tracker.renderDisplay(config.position) + tracker.firstUpdate() + } + + @SubscribeEvent + fun onIslandChange(event: IslandChangeEvent) { + if (event.newIsland == IslandType.DWARVEN_MINES) { + tracker.firstUpdate() + } } fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enabled From 2f0215784adcef0ccb58204a1138fdfc29fbb913 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 11:54:29 +0200 Subject: [PATCH 10/21] added scrap cost --- .../features/mining/ExcavatorProfitTrackerConfig.java | 2 +- .../mining/fossilexcavator/ExcavatorProfitTracker.kt | 10 +++++----- .../mining/fossilexcavator/FossilExcavatorAPI.kt | 3 +-- src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 5 +++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java index ce16f9f10263..130529cf92c3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java @@ -12,7 +12,7 @@ public class ExcavatorProfitTrackerConfig { @Expose @ConfigOption( name = "Enabled", - desc = "Count all drops you gain while excavating fossils in the Crystal Cave." + desc = "Count all drops you gain while excavating fossils in the Glacial Cave." ) @ConfigEditorBoolean @FeatureToggle diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt index e5d405675520..b410d4a74e85 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent -import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LorenzUtils @@ -110,12 +109,13 @@ class ExcavatorProfitTracker { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return - if (GardenAPI.isCurrentlyFarming()) return - // TODO add distance check -// config.showNearvy + if (LorenzUtils.skyBlockArea != "Fossil Research Center") return + // hide during an active excavation + if (FossilExcavatorAPI.inInventory && !FossilExcavatorAPI.inExcavatorMenu) { + return + } tracker.renderDisplay(config.position) - tracker.firstUpdate() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt index 7a95cdb3e368..e5191f3166a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -91,8 +91,7 @@ object FossilExcavatorAPI { val pair = itemPattern.matchMatcher(message) { val itemLine = group("item") - val newLine = itemLine.replace("§r", "") - ItemUtils.readItemAmount(newLine) ?: return + ItemUtils.readItemAmount(itemLine) ?: return } ?: return loot.add(pair) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 7f848b47fcb0..5104c52b373d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.StringUtils.removeResets import com.google.gson.GsonBuilder import com.google.gson.JsonObject import net.minecraft.client.Minecraft @@ -293,9 +294,9 @@ object ItemUtils { fun readItemAmount(originalInput: String): Pair? { // This workaround fixes 'Tubto Cacti I Book' - val input = if (originalInput.endsWith(" Book")) { + val input = (if (originalInput.endsWith(" Book")) { originalInput.replace(" Book", "") - } else originalInput + } else originalInput).removeResets() if (itemAmountCache.containsKey(input)) { return itemAmountCache[input]!! From 1952caeab51afb4a7cd11f4a7f4caa7682f78e84 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 11:56:40 +0200 Subject: [PATCH 11/21] workaround --- .../features/mining/fossilexcavator/FossilExcavatorAPI.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt index e5191f3166a1..a223ab6d772c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -91,6 +91,8 @@ object FossilExcavatorAPI { val pair = itemPattern.matchMatcher(message) { val itemLine = group("item") + // TODO fix readItemAmount bug + if (itemLine.contains("§bGlacite Powder")) return ItemUtils.readItemAmount(itemLine) ?: return } ?: return loot.add(pair) From a9b7ff7c1a59be8ba7be48388369b57d57afcb18 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:18:55 +0200 Subject: [PATCH 12/21] more fixes --- .../config/features/mining/ExcavatorProfitTrackerConfig.java | 2 +- .../features/mining/fossilexcavator/ExcavatorProfitTracker.kt | 2 +- .../features/mining/fossilexcavator/FossilExcavatorAPI.kt | 4 ++++ src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt | 2 +- .../hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java index 130529cf92c3..6c57d3b4553b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java @@ -12,7 +12,7 @@ public class ExcavatorProfitTrackerConfig { @Expose @ConfigOption( name = "Enabled", - desc = "Count all drops you gain while excavating fossils in the Glacial Cave." + desc = "Count all drops you gain while excavating in the Fossil Research Center." ) @ConfigEditorBoolean @FeatureToggle diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt index b410d4a74e85..49adb1557881 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt @@ -109,7 +109,6 @@ class ExcavatorProfitTracker { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return - if (LorenzUtils.skyBlockArea != "Fossil Research Center") return // hide during an active excavation if (FossilExcavatorAPI.inInventory && !FossilExcavatorAPI.inExcavatorMenu) { return @@ -126,4 +125,5 @@ class ExcavatorProfitTracker { } fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enabled + && LorenzUtils.skyBlockArea == "Fossil Research Center" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt index a223ab6d772c..4bc271fee2f6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -7,9 +7,13 @@ import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getPrice +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt index 97a4ab51ccec..e6a244f0960f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt @@ -53,7 +53,7 @@ object UtilsPatterns { ) val readAmountAfterPattern by patternGroup.pattern( "item.amount.behind", - "(?(?:['\\w-]+ ?)+)(?:§8x(?[\\d,]+))?" + "(?(?:§.)*(?:[^§] ?)+)(?:§8x(?[\\d,]+))?" ) val timeAmountPattern by patternGroup.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index a64471e756b5..46bb84f04db7 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -183,7 +183,7 @@ class SkyHanniItemTracker( } fun addTotalProfit(profit: Double, totalAmount: Long, action: String): Renderable { - val profitFormat = profit.addSeparators() + val profitFormat = profit.toInt().addSeparators() val profitPrefix = if (profit < 0) "§c" else "§6" val tips = if (totalAmount > 0) { From fd2b05c51413dddaebc7c8cec582a2c1252c06b8 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:23:28 +0200 Subject: [PATCH 13/21] add empty line --- .../mining/fossilexcavator/FossilExcavatorAPI.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt index 4bc271fee2f6..3c103092d553 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -40,6 +40,11 @@ object FossilExcavatorAPI { */ private val itemPattern by chatPatternGroup.pattern("item", " {4}§r(?.+)") + /** + * REGEX-TEST: §cYou didn't find anything. Maybe next time! + */ + private val emptyPattern by chatPatternGroup.pattern("empty", "§cYou didn't find anything. Maybe next time!") + private var inLoot = false private val loot = mutableListOf>() @@ -79,6 +84,11 @@ object FossilExcavatorAPI { val message = event.message + if (emptyPattern.matches(message)) { + FossilExcavationEvent(emptyList()).postAndCatch() + } + + if (startPattern.matches(message)) { inLoot = true return From 01853bc96034222be98b4a7b92928ff92f322506 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:44:31 +0200 Subject: [PATCH 14/21] remove debug --- .../mining/fossilexcavator/ExcavatorProfitTracker.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt index 49adb1557881..5ef8a712201f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt @@ -14,7 +14,6 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker @@ -93,12 +92,8 @@ class ExcavatorProfitTracker { fun onFossilExcavation(event: FossilExcavationEvent) { if (!isEnabled()) return for ((name, amount) in event.loot) { - println("") - println("name: '$name'") - println("amount: $amount") val internalName = NEUInternalName.fromItemNameOrNull(name) ?: continue - val itemStack = internalName.makePrimitiveStack(amount) - println("itemStack: '$itemStack'") + // TODO use primitive item stacks in tracker tracker.addItem(internalName, amount) } tracker.modify { From 282f0a72e2992c24e1b98d38bdef04070d2ec02f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:53:56 +0200 Subject: [PATCH 15/21] Only show in excavation menu --- .../mining/fossilexcavator/ExcavatorProfitTracker.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt index 5ef8a712201f..bf1ed4f90fe7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt @@ -18,6 +18,8 @@ import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker import com.google.gson.annotations.Expose +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ExcavatorProfitTracker { @@ -104,9 +106,12 @@ class ExcavatorProfitTracker { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return - // hide during an active excavation - if (FossilExcavatorAPI.inInventory && !FossilExcavatorAPI.inExcavatorMenu) { - return + val inChest = Minecraft.getMinecraft().currentScreen is GuiChest + if (inChest) { + // Only show in excavation menu + if (!FossilExcavatorAPI.inExcavatorMenu) { + return + } } tracker.renderDisplay(config.position) From 54bb808fd45c9159fedd85c2384a4ad17b8773b4 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:30:07 +0200 Subject: [PATCH 16/21] fix coordinate mixup --- .../config/features/mining/ExcavatorProfitTrackerConfig.java | 2 +- .../config/features/mining/FossilExcavatorSolverConfig.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java index 6c57d3b4553b..d57352e58937 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java @@ -28,5 +28,5 @@ public class ExcavatorProfitTrackerConfig { @Expose @ConfigLink(owner = ExcavatorProfitTrackerConfig.class, field = "enabled") - public Position position = new Position(20, 20, false, true); + public Position position = new Position(-380, 150, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorSolverConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorSolverConfig.java index 94ce05f07f13..6b881f7d7109 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorSolverConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorSolverConfig.java @@ -24,5 +24,5 @@ public class FossilExcavatorSolverConfig { @Expose @ConfigLink(owner = FossilExcavatorSolverConfig.class, field = "enabled") - public Position position = new Position(-380, 150, false, true); + public Position position = new Position(183, 212, false, true); } From 9667a627cab7b6384ceb03a1bb49c963f51e5f3d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:35:17 +0200 Subject: [PATCH 17/21] Update src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../skyhanni/features/inventory/HideNotClickableItems.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index 977e8b426da1..c10ad6a37756 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -246,7 +246,7 @@ class HideNotClickableItems { return false } - hideReason = "§cNo fossil!" + hideReason = "§cNot a fossil!" return true } From cd5d02992f6a1186bddd31831d0c170de28b85a0 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:35:23 +0200 Subject: [PATCH 18/21] Update src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../skyhanni/features/inventory/HideNotClickableItems.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index c10ad6a37756..20c042f64390 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -223,7 +223,7 @@ class HideNotClickableItems { return false } - hideReason = "§cNo chisel or scrap!" + hideReason = "§cNot a chisel or scrap!" return true } From 3375c39af5c21279076a7d410baf8f8f7ded288c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:46:29 +0200 Subject: [PATCH 19/21] Delete src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt --- .../mining/fossilexcavator/FossilExcavatorProfitTracker.kt | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt deleted file mode 100644 index 57e9f00b9781..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorProfitTracker.kt +++ /dev/null @@ -1,4 +0,0 @@ -package at.hannibal2.skyhanni.features.mining.fossilexcavator - -class FossilExcavatorProfitTracker { -} From 022142966c425accc816734e1601a1ac00a5332a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:00:13 +0200 Subject: [PATCH 20/21] Track Glacite Powder --- .../mining/ExcavatorProfitTrackerConfig.java | 6 +- .../fossilexcavator/ExcavatorProfitTracker.kt | 71 ++++++++++++++++--- .../fossilexcavator/FossilExcavatorAPI.kt | 9 +-- 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java index d57352e58937..97a1933f1d0d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorProfitTrackerConfig.java @@ -20,11 +20,11 @@ public class ExcavatorProfitTrackerConfig { @Expose @ConfigOption( - name = "Show nearby", - desc = "Show the profit tracker while close to the excavation point." + name = "Track Glacite Powder", + desc = "Track Glacite Powder gained as well (no profit, but progress)" ) @ConfigEditorBoolean - public boolean showNearvy = true; + public boolean trackGlacitePowder = true; @Expose @ConfigLink(owner = ExcavatorProfitTrackerConfig.class, field = "enabled") diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt index bf1ed4f90fe7..d9beb947d807 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LorenzUtils @@ -55,6 +56,8 @@ class ExcavatorProfitTracker { @Expose var timesExcavated = 0L + var glacitePowderGained = 0L + var fossilDustGained = 0L } private val scrapItem = "SUSPICIOUS_SCRAP".asInternalName() @@ -72,8 +75,36 @@ class ExcavatorProfitTracker { ) // TODO use same price source as profit tracker + profit = addScrap(timesExcavated, profit) + if (config.trackGlacitePowder) { + addGlacitePowder(data) + } + + addAsSingletonList(tracker.addTotalProfit(profit, data.timesExcavated, "excarvation")) + + tracker.addPriceFromButton(this) + } + + private fun MutableList>.addGlacitePowder(data: Data) { + val glacitePowderGained = data.glacitePowderGained + if (glacitePowderGained <= 0) return + addAsSingletonList( + Renderable.hoverTips( + "§bGlacite Powder§7: §e${glacitePowderGained.addSeparators()}", + listOf( + "§7No real profit,", + "§7but still nice to see! Right?", + ) + ) + ) + } + + private fun MutableList>.addScrap( + timesExcavated: Long, + profit: Double, + ): Double { + if (timesExcavated <= 0) return profit val scrapPrice = timesExcavated * scrapItem.getPrice() - profit -= scrapPrice addAsSingletonList( Renderable.hoverTips( "${scrapItem.itemName}§7: §c${NumberUtil.format(scrapPrice)}", @@ -84,31 +115,53 @@ class ExcavatorProfitTracker { ) ) ) - - addAsSingletonList(tracker.addTotalProfit(profit, data.timesExcavated, "excarvation")) - - tracker.addPriceFromButton(this) + return profit - scrapPrice } @SubscribeEvent fun onFossilExcavation(event: FossilExcavationEvent) { if (!isEnabled()) return for ((name, amount) in event.loot) { - val internalName = NEUInternalName.fromItemNameOrNull(name) ?: continue - // TODO use primitive item stacks in tracker - tracker.addItem(internalName, amount) + addItem(name, amount) } tracker.modify { it.timesExcavated++ } } + private fun addItem(name: String, amount: Int) { + if (name == "§bGlacite Powder") { + if (config.trackGlacitePowder) { + tracker.modify { + it.glacitePowderGained += amount + } + } + return + } + if (name == "§fFossil Dust") { + // TODO calculate profit and show + ChatUtils.debug("fossilDustGained: +$amount") + tracker.modify { + it.fossilDustGained += amount + } + return + } + + val internalName = NEUInternalName.fromItemNameOrNull(name) + if (internalName == null) { + ChatUtils.debug("no price for exavator profit: '$name'") + return + } + // TODO use primitive item stacks in trackers + tracker.addItem(internalName, amount) + } + @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return val inChest = Minecraft.getMinecraft().currentScreen is GuiChest if (inChest) { - // Only show in excavation menu + // Only show in excavation menu if (!FossilExcavatorAPI.inExcavatorMenu) { return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt index 3c103092d553..40971c87e49d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -7,13 +7,9 @@ import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent -import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -104,10 +100,7 @@ object FossilExcavatorAPI { } val pair = itemPattern.matchMatcher(message) { - val itemLine = group("item") - // TODO fix readItemAmount bug - if (itemLine.contains("§bGlacite Powder")) return - ItemUtils.readItemAmount(itemLine) ?: return + ItemUtils.readItemAmount(group("item")) } ?: return loot.add(pair) } From e54690b178b637f9f1e01ef9e9e9376605b0e964 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 13 Apr 2024 09:30:17 +0200 Subject: [PATCH 21/21] fix config --- .../at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt | 2 +- .../mining/fossilexcavator/solver/FossilSolverDisplay.kt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 7907c0f37b8e..75569686c800 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -11,7 +11,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 35 + const val CONFIG_VERSION = 36 fun JsonElement.at(chain: List, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt index 3b844d233084..590575ecdbdb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.SkyHanniMod.Companion.coroutineScope +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -207,6 +208,11 @@ object FossilSolverDisplay { config.position.renderStrings(displayList, posLabel = "Fossil Excavator Solver") } + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(36, "mining.fossilExcavator", "mining.fossilExcavator.solver") + } + fun nextData(slotToClick: FossilTile, correctPercentage: Double, fossilsRemaining: Int) { val formattedPercentage = (correctPercentage * 100).round(1)