diff options
author | Linnea Gräf <nea@nea.moe> | 2024-12-19 21:26:48 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-12-19 21:26:48 +0100 |
commit | 7c4b2e089fa23622799bc06a08f6932197365368 (patch) | |
tree | 68dd5901fdb587639bda530f3674fb9606fa971a /src/main | |
parent | 7e007e7a9adf550e70b809ce8239dd9b5a15d45c (diff) | |
download | LocalTransactionLedger-7c4b2e089fa23622799bc06a08f6932197365368.tar.gz LocalTransactionLedger-7c4b2e089fa23622799bc06a08f6932197365368.tar.bz2 LocalTransactionLedger-7c4b2e089fa23622799bc06a08f6932197365368.zip |
feat: Forge detection
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/Ledger.kt | 3 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/TransactionType.kt | 1 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/modules/ForgeDetection.kt | 48 |
3 files changed, 52 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/Ledger.kt b/src/main/kotlin/moe/nea/ledger/Ledger.kt index 2f828b0..bb69621 100644 --- a/src/main/kotlin/moe/nea/ledger/Ledger.kt +++ b/src/main/kotlin/moe/nea/ledger/Ledger.kt @@ -16,6 +16,7 @@ import moe.nea.ledger.modules.BitsDetection import moe.nea.ledger.modules.BitsShopDetection import moe.nea.ledger.modules.DungeonChestDetection import moe.nea.ledger.modules.ExternalDataProvider +import moe.nea.ledger.modules.ForgeDetection import moe.nea.ledger.modules.GambleDetection import moe.nea.ledger.modules.KatDetection import moe.nea.ledger.modules.KuudraChestDetection @@ -87,6 +88,7 @@ class Ledger { fun runLater(runnable: Runnable) { tickQueue.add(runnable) } + val di = DI() } @@ -118,6 +120,7 @@ class Ledger { LogChatCommand::class.java, MinionDetection::class.java, MineshaftCorpseDetection::class.java, + ForgeDetection::class.java, NpcDetection::class.java, GambleDetection::class.java, QueryCommand::class.java, diff --git a/src/main/kotlin/moe/nea/ledger/TransactionType.kt b/src/main/kotlin/moe/nea/ledger/TransactionType.kt index 7521672..f6bbe6a 100644 --- a/src/main/kotlin/moe/nea/ledger/TransactionType.kt +++ b/src/main/kotlin/moe/nea/ledger/TransactionType.kt @@ -15,6 +15,7 @@ enum class TransactionType { BOOSTER_COOKIE_ATE, COMMUNITY_SHOP_BUY, CORPSE_DESECRATED, + FORGED, DIE_ROLLED, DUNGEON_CHEST_OPEN, KAT_TIMESKIP, diff --git a/src/main/kotlin/moe/nea/ledger/modules/ForgeDetection.kt b/src/main/kotlin/moe/nea/ledger/modules/ForgeDetection.kt new file mode 100644 index 0000000..95811ed --- /dev/null +++ b/src/main/kotlin/moe/nea/ledger/modules/ForgeDetection.kt @@ -0,0 +1,48 @@ +package moe.nea.ledger.modules + +import moe.nea.ledger.ItemChange +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.matches +import moe.nea.ledger.unformattedString +import moe.nea.ledger.utils.di.Inject +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.time.Instant + +class ForgeDetection { + val furnaceSlot = 9 + 4 + val furnaceName = "Forge Slot.*".toPattern() + + @SubscribeEvent + fun onClick(event: GuiClickEvent) { + val slot = event.slotIn ?: return + val clickedItem = slot.stack ?: return + if (clickedItem.displayName.unformattedString() != "Confirm") return + val furnaceSlotName = slot.inventory.getStackInSlot(furnaceSlot)?.displayName?.unformattedString() ?: return + if (!furnaceName.matches(furnaceSlotName)) + return + val cl = (0 until slot.inventory.sizeInventory - 9) + .mapNotNull { + val stack = slot.inventory.getStackInSlot(it) ?: return@mapNotNull null + val x = it % 9 + if (x == 4) return@mapNotNull null + ItemChange( + stack.getInternalId() ?: return@mapNotNull null, + stack.stackSize.toDouble(), + if (x < 4) ItemChange.ChangeDirection.LOST else ItemChange.ChangeDirection.GAINED + ) + } + logger.logEntry(LedgerEntry( + TransactionType.FORGED, + Instant.now(), + cl, + )) + } + + @Inject + lateinit var logger: LedgerLogger + +}
\ No newline at end of file |