diff options
author | Linnea Gräf <nea@nea.moe> | 2025-01-25 20:02:18 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-01-25 20:02:31 +0100 |
commit | d6a71bcfa4b1e1ea4d2864fae3c16791b63794ee (patch) | |
tree | 070b90f948ca2b46d9216e3adb1e7c6cc5d01c99 | |
parent | 02830fc904792aa1945f5072e0815dbf02baebe7 (diff) | |
download | LocalTransactionLedger-d6a71bcfa4b1e1ea4d2864fae3c16791b63794ee.tar.gz LocalTransactionLedger-d6a71bcfa4b1e1ea4d2864fae3c16791b63794ee.tar.bz2 LocalTransactionLedger-d6a71bcfa4b1e1ea4d2864fae3c16791b63794ee.zip |
feat: Add fed pet to caducous feeder
-rw-r--r-- | mod/src/main/kotlin/moe/nea/ledger/modules/CaducousFeederDetection.kt | 50 |
1 files changed, 26 insertions, 24 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 index 76374ef..b64c7e5 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/CaducousFeederDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/CaducousFeederDetection.kt @@ -1,6 +1,7 @@ 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 @@ -16,31 +17,32 @@ import java.time.Instant class CaducousFeederDetection { - @Inject - lateinit var logger: LedgerLogger + @Inject + lateinit var logger: LedgerLogger - @Inject - lateinit var minecraft: Minecraft + @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 - val hasCarrotCandy = player.inventory.mainInventory.any { it?.getInternalId() == ItemIds.ULTIMATE_CARROT_CANDY } + @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 - if (hasCarrotCandy && stack.getDisplayNameU() == "§aUse Caducous Feeder") { - logger.logEntry( - LedgerEntry( - TransactionType.CADUCOUS_FEEDER_USED, - Instant.now(), - listOf( - ItemChange.lose(ItemIds.ULTIMATE_CARROT_CANDY, 1) - ) - ) - ) - } - } + 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 |