aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-04-12 12:58:14 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-04-12 12:58:14 +0200
commit887885e17953eee1c8004648ba3fddef471d23cf (patch)
tree6608097308afc81e434957b4e8b6f7ff261af6ee /src/main/java/at/hannibal2
parent852c74feb82e55d9b08424887271399c6e038e64 (diff)
parentdcdea84e7acc5431c5257ef8348a77b7d4de9bc7 (diff)
downloadskyhanni-887885e17953eee1c8004648ba3fddef471d23cf.tar.gz
skyhanni-887885e17953eee1c8004648ba3fddef471d23cf.tar.bz2
skyhanni-887885e17953eee1c8004648ba3fddef471d23cf.zip
Merge remote-tracking branch 'origin/beta' into beta
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt4
-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/solver/FossilExcavator.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavator.kt)34
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavatorSolver.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorSolver.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilMutation.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilMutation.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilShape.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilShape.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilTile.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilTile.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilType.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilType.kt)2
8 files changed, 61 insertions, 31 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index bb1e05cfc..622d8adfa 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 000000000..bb9e2c30b
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt
@@ -0,0 +1,44 @@
+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/FossilExcavator.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilExcavator.kt
index e1c46e12e..078e96d54 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: (?<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
@@ -64,13 +63,6 @@ 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()
}
@@ -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
index b12e33674..18c256529 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
index f039b2ef0..724e2a5aa 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
index c30bb9175..ae8b25593 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<FossilTile>) {
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
index 1c6ba7070..e671633cb 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
index 208dfac96..e97271dfb 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,