Skip to content

Commit

Permalink
feat: AutoTotem taking modes (#3959)
Browse files Browse the repository at this point in the history
  • Loading branch information
d1n3x3z7 authored Sep 30, 2024
1 parent cfda65f commit 9f3fac3
Showing 1 changed file with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
*/
package net.ccbluex.liquidbounce.features.module.modules.player

import net.ccbluex.liquidbounce.config.NamedChoice
import net.ccbluex.liquidbounce.config.ToggleableConfigurable
import net.ccbluex.liquidbounce.event.events.ScheduleInventoryActionEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleAutoTotem.Health.doesNotPassHealth
import net.ccbluex.liquidbounce.features.module.modules.player.invcleaner.HotbarItemSlot
import net.ccbluex.liquidbounce.features.module.modules.player.invcleaner.OffHandSlot
import net.ccbluex.liquidbounce.utils.inventory.ClickInventoryAction
import net.ccbluex.liquidbounce.utils.inventory.PlayerInventoryConstraints
Expand All @@ -48,6 +50,8 @@ object ModuleAutoTotem : Module("AutoTotem", Category.PLAYER) {

}

private val swapMode by enumChoice("Mode", SwapTotemMode.OFFHANDPICKUP)

init {
tree(Health)
}
Expand All @@ -62,6 +66,53 @@ object ModuleAutoTotem : Module("AutoTotem", Category.PLAYER) {
}

val slot = findInventorySlot { it.item == Items.TOTEM_OF_UNDYING } ?: return@handler
it.schedule(inventoryConstraints, ClickInventoryAction.performSwap(from = slot, to = OffHandSlot))
val action = when (swapMode) {
SwapTotemMode.OFFHANDPICKUP -> {
val isOffhandEmpty = OffHandSlot.itemStack.isEmpty

listOfNotNull(
ClickInventoryAction.performPickup(slot = slot),
ClickInventoryAction.performPickup(slot = OffHandSlot),

if (!isOffhandEmpty) ClickInventoryAction.performPickup(slot = slot) else null,
)
}

SwapTotemMode.SWAP -> {
listOf(
ClickInventoryAction.performSwap(from = slot, to = OffHandSlot)
)
}

SwapTotemMode.HOTBARPICKUP -> {
val activeSlot = HotbarItemSlot(player.inventory.swappableHotbarSlot)
val isSlotEmpty = activeSlot.itemStack.isEmpty
val isOffhandEmpty = OffHandSlot.itemStack.isEmpty

listOfNotNull(
ClickInventoryAction.performPickup(slot = slot),
ClickInventoryAction.performPickup(slot = activeSlot),

if (!isSlotEmpty) ClickInventoryAction.performPickup(slot = slot) else null,

ClickInventoryAction.performPickup(slot = activeSlot),
ClickInventoryAction.performPickup(slot = OffHandSlot),

if (!isOffhandEmpty) ClickInventoryAction.performPickup(slot = activeSlot) else null,

if (!isSlotEmpty) ClickInventoryAction.performPickup(slot = slot) else null,
if (!isSlotEmpty) ClickInventoryAction.performPickup(slot = activeSlot) else null,

if (!isOffhandEmpty && !isSlotEmpty) ClickInventoryAction.performPickup(slot = slot) else null,
)
}
}
it.schedule(inventoryConstraints, action)
}

enum class SwapTotemMode(override val choiceName: String) : NamedChoice {
SWAP("Swap"),
OFFHANDPICKUP("OffhandPickup"),
HOTBARPICKUP("HotbarPickup"),
}
}

0 comments on commit 9f3fac3

Please sign in to comment.