aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavator.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavator.kt)34
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt44
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorSolver.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavatorSolver.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilMutation.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilMutation.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilShape.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilShape.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilTile.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilTile.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilType.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilType.kt)2
8 files changed, 31 insertions, 61 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 622d8adfa..bb1e05cfc 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -268,8 +268,7 @@ 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.FossilExcavatorAPI
-import at.hannibal2.skyhanni.features.mining.fossilexcavator.solver.FossilExcavator
+import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavator
import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker
import at.hannibal2.skyhanni.features.minion.InfernoMinionFeatures
import at.hannibal2.skyhanni.features.minion.MinionCollectLogic
@@ -537,7 +536,6 @@ 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/solver/FossilExcavator.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavator.kt
index 078e96d54..e1c46e12e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavator.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver
+package at.hannibal2.skyhanni.features.mining.fossilexcavator
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,7 +38,8 @@ object FossilExcavator {
"Fossil Excavation Progress: (?<progress>[\\d.]+%)"
)
- private val inExcavatorMenu get() = FossilExcavatorAPI.inExcavatorMenu
+ private var inInventory = false
+ private var inExcavatorMenu = false
private var foundPercentage = false
private var percentage: String? = null
@@ -63,6 +64,13 @@ object FossilExcavator {
var possibleFossilTypes = setOf<FossilType>()
@SubscribeEvent
+ fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
+ if (!isEnabled()) return
+ if (event.inventoryName != "Fossil Excavator") return
+ inInventory = true
+ }
+
+ @SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
clearData()
}
@@ -73,6 +81,8 @@ object FossilExcavator {
}
private fun clearData() {
+ inInventory = false
+ inExcavatorMenu = false
foundPercentage = false
percentage = null
chargesRemaining = 0
@@ -87,10 +97,12 @@ 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()
@@ -141,6 +153,7 @@ object FossilExcavator {
@SubscribeEvent
fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
if (!isEnabled()) return
+ if (!inInventory) return
if (inExcavatorMenu) return
event.makePickblock()
@@ -155,6 +168,7 @@ object FossilExcavator {
@SubscribeEvent
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!isEnabled()) return
+ if (!inInventory) return
if (inExcavatorMenu) return
if (slotToClick == null) return
@@ -168,6 +182,7 @@ 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
@@ -181,6 +196,7 @@ 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
@@ -193,9 +209,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:")
@@ -210,9 +226,9 @@ object FossilExcavator {
fun nextData(slotToClick: FossilTile, correctPercentage: Double, fossilsRemaining: Int) {
val formattedPercentage = (correctPercentage * 100).round(1)
- possibleFossilsRemaining = fossilsRemaining
- FossilExcavator.slotToClick = slotToClick.toSlotIndex()
- FossilExcavator.correctPercentage = "§2$formattedPercentage%"
+ this.possibleFossilsRemaining = fossilsRemaining
+ this.slotToClick = slotToClick.toSlotIndex()
+ this.correctPercentage = "§2$formattedPercentage%"
}
fun showError() {
@@ -223,5 +239,5 @@ object FossilExcavator {
isCompleted = true
}
- private fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enabled && FossilExcavatorAPI.inInventory
+ private fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enabled
}
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
deleted file mode 100644
index bb9e2c30b..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-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
-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
- }
-
- @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" }
- }
-
- @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/solver/FossilExcavatorSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorSolver.kt
index 18c256529..b12e33674 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavatorSolver.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorSolver.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver
+package at.hannibal2.skyhanni.features.mining.fossilexcavator
object FossilExcavatorSolver {
/*
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilMutation.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilMutation.kt
index 724e2a5aa..f039b2ef0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilMutation.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilMutation.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver
+package at.hannibal2.skyhanni.features.mining.fossilexcavator
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/solver/FossilShape.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilShape.kt
index ae8b25593..c30bb9175 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilShape.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilShape.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver
+package at.hannibal2.skyhanni.features.mining.fossilexcavator
data class FossilShape(val tiles: List<FossilTile>) {
fun width() = tiles.maxOf { it.x } - tiles.minOf { it.x }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilTile.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilTile.kt
index e671633cb..1c6ba7070 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilTile.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilTile.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver
+package at.hannibal2.skyhanni.features.mining.fossilexcavator
data class FossilTile(val x: Int, val y: Int) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilType.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilType.kt
index e97271dfb..208dfac96 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilType.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.mining.fossilexcavator.solver
+package at.hannibal2.skyhanni.features.mining.fossilexcavator
enum class FossilType(
val displayName: String,