aboutsummaryrefslogtreecommitdiff
path: root/mod/src
diff options
context:
space:
mode:
Diffstat (limited to 'mod/src')
-rw-r--r--mod/src/main/java/moe/nea/ledger/init/AutoDiscoveryMixinPlugin.java2
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/Ledger.kt4
-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
4 files changed, 92 insertions, 0 deletions
diff --git a/mod/src/main/java/moe/nea/ledger/init/AutoDiscoveryMixinPlugin.java b/mod/src/main/java/moe/nea/ledger/init/AutoDiscoveryMixinPlugin.java
index 56841b5..64fa6c2 100644
--- a/mod/src/main/java/moe/nea/ledger/init/AutoDiscoveryMixinPlugin.java
+++ b/mod/src/main/java/moe/nea/ledger/init/AutoDiscoveryMixinPlugin.java
@@ -96,6 +96,8 @@ public class AutoDiscoveryMixinPlugin implements IMixinConfigPlugin {
* @param className the name or path of a class to be registered as a mixin.
*/
public void tryAddMixinClass(String className) {
+ if (!className.endsWith(".class")) return;
+ if (className.indexOf('$') >= 0) return;
String norm = (className.endsWith(".class") ? className.substring(0, className.length() - ".class".length()) : className)
.replace("\\", "/")
.replace("/", ".");
diff --git a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt
index 134d519..9bbc8e1 100644
--- a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt
+++ b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt
@@ -22,6 +22,7 @@ import moe.nea.ledger.modules.BazaarDetection
import moe.nea.ledger.modules.BazaarOrderDetection
import moe.nea.ledger.modules.BitsDetection
import moe.nea.ledger.modules.BitsShopDetection
+import moe.nea.ledger.modules.CaducousFeederDetection
import moe.nea.ledger.modules.DragonEyePlacementDetection
import moe.nea.ledger.modules.DragonSacrificeDetection
import moe.nea.ledger.modules.DungeonChestDetection
@@ -29,6 +30,7 @@ import moe.nea.ledger.modules.ExternalDataProvider
import moe.nea.ledger.modules.EyedropsDetection
import moe.nea.ledger.modules.ForgeDetection
import moe.nea.ledger.modules.GambleDetection
+import moe.nea.ledger.modules.GhostCoinDropDetection
import moe.nea.ledger.modules.GodPotionDetection
import moe.nea.ledger.modules.GodPotionMixinDetection
import moe.nea.ledger.modules.GummyPolarBearDetection
@@ -135,6 +137,7 @@ class Ledger {
BazaarOrderDetection::class.java,
BitsDetection::class.java,
BitsShopDetection::class.java,
+ CaducousFeederDetection::class.java,
ConfigCommand::class.java,
DebugDataCommand::class.java,
DragonEyePlacementDetection::class.java,
@@ -145,6 +148,7 @@ class Ledger {
EyedropsDetection::class.java,
ForgeDetection::class.java,
GambleDetection::class.java,
+ GhostCoinDropDetection::class.java,
GodPotionDetection::class.java,
GodPotionMixinDetection::class.java,
GummyPolarBearDetection::class.java,
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"))),
+ )
+ )
+ )
+ }
+ }
+}