aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-01-25 20:02:18 +0100
committerLinnea Gräf <nea@nea.moe>2025-01-25 20:02:31 +0100
commitd6a71bcfa4b1e1ea4d2864fae3c16791b63794ee (patch)
tree070b90f948ca2b46d9216e3adb1e7c6cc5d01c99
parent02830fc904792aa1945f5072e0815dbf02baebe7 (diff)
downloadLocalTransactionLedger-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.kt50
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