aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-12-07 23:10:13 +0100
committerLinnea Gräf <nea@nea.moe>2024-12-07 23:10:13 +0100
commit3acf36fbd07686431b8fbb5484f1f70b52651dc5 (patch)
tree2e7a582bc481c73bbd268a6fe8de57e5a5cf4e95 /src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt
parent0ca988c907c7e8e26029f59cc098e6be5e008ee5 (diff)
downloadLocalTransactionLedger-3acf36fbd07686431b8fbb5484f1f70b52651dc5.tar.gz
LocalTransactionLedger-3acf36fbd07686431b8fbb5484f1f70b52651dc5.tar.bz2
LocalTransactionLedger-3acf36fbd07686431b8fbb5484f1f70b52651dc5.zip
Add kuudra chest detection
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt')
-rw-r--r--src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt b/src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt
new file mode 100644
index 0000000..bc072ba
--- /dev/null
+++ b/src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt
@@ -0,0 +1,45 @@
+package moe.nea.ledger.modules
+
+import moe.nea.ledger.ItemChange
+import moe.nea.ledger.ItemId
+import moe.nea.ledger.LedgerEntry
+import moe.nea.ledger.LedgerLogger
+import moe.nea.ledger.TransactionType
+import moe.nea.ledger.events.GuiClickEvent
+import moe.nea.ledger.getInternalId
+import moe.nea.ledger.utils.Inject
+import net.minecraft.client.Minecraft
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class KuudraChestDetection : ChestDetection() {
+ // TODO: extra essence for kuudra pet (how?), item SALVAGE detection
+ // TODO: save uuid along side item id
+
+ val kuudraKeyPattern = "KUUDRA_.*_TIER_KEY".toPattern()
+
+ @Inject
+ lateinit var log: LedgerLogger
+
+ @Inject
+ lateinit var minecraft: Minecraft
+ fun hasKey(keyItem: ItemId): Boolean {
+ val p = minecraft.thePlayer ?: return false
+ return p.inventory.mainInventory.any { it.getInternalId() == keyItem }
+ }
+
+ @SubscribeEvent
+ fun onRewardChestClick(event: GuiClickEvent) {
+ val diffs = scrapeChestReward(event.slotIn ?: return) ?: return
+ val requiredKey = diffs.diff.find {
+ it.direction == ItemChange.ChangeDirection.LOST && kuudraKeyPattern.asPredicate().test(it.itemId.string)
+ }?.itemId
+ if (requiredKey != null && !hasKey(requiredKey)) {
+ return
+ }
+ log.logEntry(LedgerEntry(
+ TransactionType.KUUDRA_CHEST_OPEN,
+ diffs.timestamp,
+ diffs.diff,
+ ))
+ }
+} \ No newline at end of file