diff options
Diffstat (limited to 'mod/src/main/kotlin/moe/nea/ledger/modules/CaducousFeederDetection.kt')
-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 |