aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/kotlin/moe/nea/ledger/modules
diff options
context:
space:
mode:
Diffstat (limited to 'mod/src/main/kotlin/moe/nea/ledger/modules')
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/CaducousFeederDetection.kt48
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/GhostCoinDropDetection.kt38
2 files changed, 86 insertions, 0 deletions
diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/CaducousFeederDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/CaducousFeederDetection.kt
new file mode 100644
index 0000000..b64c7e5
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/modules/CaducousFeederDetection.kt
@@ -0,0 +1,48 @@
+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.gen.ItemIds
+import moe.nea.ledger.getDisplayNameU
+import moe.nea.ledger.getInternalId
+import moe.nea.ledger.unformattedString
+import moe.nea.ledger.utils.di.Inject
+import net.minecraft.client.Minecraft
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.time.Instant
+
+class CaducousFeederDetection {
+
+ @Inject
+ lateinit var logger: LedgerLogger
+
+ @Inject
+ lateinit var minecraft: Minecraft
+
+ @SubscribeEvent
+ fun onFeederClick(event: GuiClickEvent) {
+ val slot = event.slotIn ?: return
+ val displayName = slot.inventory.displayName.unformattedText
+ if (!displayName.unformattedString().contains("Confirm Caducous Feeder")) return
+ val stack = slot.stack ?: return
+ val player = minecraft.thePlayer ?: return
+ if (!player.inventory.mainInventory.any { it?.getInternalId() == ItemIds.ULTIMATE_CARROT_CANDY }) return
+ if (stack.getDisplayNameU() != "§aUse Caducous Feeder") return
+ val petId = slot.inventory.getStackInSlot(13)?.getInternalId() ?: ItemId.NIL
+
+ logger.logEntry(
+ LedgerEntry(
+ TransactionType.CADUCOUS_FEEDER_USED,
+ Instant.now(),
+ listOf(
+ ItemChange.lose(ItemIds.ULTIMATE_CARROT_CANDY, 1),
+ ItemChange(petId, 1.0, ItemChange.ChangeDirection.TRANSFORM),
+ )
+ )
+ )
+ }
+} \ No newline at end of file
diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/GhostCoinDropDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/GhostCoinDropDetection.kt
new file mode 100644
index 0000000..42084e2
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/modules/GhostCoinDropDetection.kt
@@ -0,0 +1,38 @@
+package moe.nea.ledger.modules
+
+import moe.nea.ledger.ItemChange
+import moe.nea.ledger.LedgerEntry
+import moe.nea.ledger.LedgerLogger
+import moe.nea.ledger.SHORT_NUMBER_PATTERN
+import moe.nea.ledger.TransactionType
+import moe.nea.ledger.events.ChatReceived
+import moe.nea.ledger.parseShortNumber
+import moe.nea.ledger.useMatcher
+import moe.nea.ledger.utils.di.Inject
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+class GhostCoinDropDetection {
+
+ val ghostCoinPattern =
+ Pattern.compile("The ghost's death materialized (?<coins>$SHORT_NUMBER_PATTERN) coins from the mists!")
+
+ @Inject
+ lateinit var logger: LedgerLogger
+
+ @SubscribeEvent
+ fun onGhostCoinDrop(event: ChatReceived) {
+ ghostCoinPattern.useMatcher(event.message) {
+ logger.logEntry(
+ LedgerEntry(
+ // TODO: merge this into a generic mob drop tt
+ TransactionType.GHOST_COIN_DROP,
+ event.timestamp,
+ listOf(
+ ItemChange.gainCoins(parseShortNumber(group("coins"))),
+ )
+ )
+ )
+ }
+ }
+}