Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ccetl committed Oct 18, 2024
1 parent ae6a527 commit c26c4b0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object ModuleOffhand : Module("Offhand", Category.PLAYER, aliases = arrayOf("Aut
}

private object Crystal : ToggleableConfigurable(this, "Crystal", true) {
val onlyWhileCa by boolean("OnlyWhileCrystalAura", true)
val onlyWhileCa by boolean("OnlyWhileCrystalAura", false)
val whenNoTotems by boolean("WhenNoTotems", true)
val crystalBind by key("CrystalBind", GLFW.GLFW_KEY_UNKNOWN)
}
Expand All @@ -82,6 +82,8 @@ object ModuleOffhand : Module("Offhand", Category.PLAYER, aliases = arrayOf("Aut
private var lastMode: Mode? = null
private var lastTagMode: Mode = Mode.NONE
private var staticMode = Mode.NONE
private var modeBeforeDirectGapple = Mode.NONE
private var modeBeforeDirectCrystal = Mode.NONE
private var last: Pair<Item, ItemSlot>? = null

override val tag: String
Expand All @@ -104,13 +106,21 @@ object ModuleOffhand : Module("Offhand", Category.PLAYER, aliases = arrayOf("Aut

when (it.key.keyCode) {
Gapple.gappleBind -> {
if (Mode.GAPPLE.canCycleTo()) {
activeMode = Mode.GAPPLE
if (activeMode == Mode.GAPPLE && modeBeforeDirectGapple.canCycleTo()) {
modeBeforeDirectGapple = Mode.NONE
staticMode = modeBeforeDirectGapple
} else if (Mode.GAPPLE.canCycleTo()) {
modeBeforeDirectGapple = staticMode
staticMode = Mode.GAPPLE
}
}
Crystal.crystalBind -> {
if (Mode.CRYSTAL.canCycleTo()) {
activeMode = Mode.CRYSTAL
if (activeMode == Mode.CRYSTAL && modeBeforeDirectCrystal.canCycleTo()) {
modeBeforeDirectCrystal = Mode.NONE
staticMode = modeBeforeDirectCrystal
} else if (Mode.CRYSTAL.canCycleTo()) {
modeBeforeDirectCrystal = staticMode
staticMode = Mode.CRYSTAL
}
}
cycleSlots -> {
Expand All @@ -132,7 +142,7 @@ object ModuleOffhand : Module("Offhand", Category.PLAYER, aliases = arrayOf("Aut
}

@Suppress("unused")
private val autoTotemHandler = handler<ScheduleInventoryActionEvent> {
private val autoTotemHandler = handler<ScheduleInventoryActionEvent>(priority = 100) {
activeMode = Mode.entries.firstOrNull(Mode::shouldEquip) ?: staticMode
if (activeMode == Mode.NONE && Totem.Health.switchBack && lastMode == Mode.TOTEM) {
activeMode = Mode.BACK
Expand Down Expand Up @@ -171,7 +181,9 @@ object ModuleOffhand : Module("Offhand", Category.PLAYER, aliases = arrayOf("Aut
}
}

it.schedule(inventoryConstraints, actions)
if (activeMode != Mode.TOTEM || !totem.send(actions)) {
it.schedule(inventoryConstraints, actions)
}
chronometer.reset()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import net.ccbluex.liquidbounce.features.module.modules.player.nofall.ModuleNoFa
import net.ccbluex.liquidbounce.utils.block.isFallDamageBlocking
import net.ccbluex.liquidbounce.utils.entity.*
import net.ccbluex.liquidbounce.utils.inventory.ARMOR_SLOTS
import net.ccbluex.liquidbounce.utils.inventory.ClickInventoryAction
import net.ccbluex.liquidbounce.utils.inventory.InventoryManager
import net.minecraft.entity.EntityPose

class Totem : ToggleableConfigurable(ModuleOffhand, "Totem", true) {
Expand Down Expand Up @@ -100,7 +102,7 @@ class Totem : ToggleableConfigurable(ModuleOffhand, "Totem", true) {

//val mainHand by boolean("MainHand", false)

fun healthAboveThreshold():Boolean {
fun healthBellowThreshold(): Boolean {
if (!enabled) {
return true
}
Expand Down Expand Up @@ -128,7 +130,7 @@ class Totem : ToggleableConfigurable(ModuleOffhand, "Totem", true) {

val safetyOperating = Safety.enabled && currentHealth > Safety.safeHealth
if (safetyOperating && (player.isBurrowed() || player.isInHole())) {
return true
return false
}

return currentHealth <= healthThreshold
Expand All @@ -140,6 +142,11 @@ class Totem : ToggleableConfigurable(ModuleOffhand, "Totem", true) {
tree(Health)
}

/**
* Ignores all active inventory requests, switch settings and sends the switch packets directly.
*/
private val sendDirectly by boolean("SendDirectly", false)

fun shouldEquip(): Boolean {
if (!enabled) {
return false
Expand All @@ -149,7 +156,20 @@ class Totem : ToggleableConfigurable(ModuleOffhand, "Totem", true) {
return false
}

return Health.healthAboveThreshold()
return Health.healthBellowThreshold()
}

/**
* @return `true` if the [actions] got performed.
*/
fun send(actions: List<ClickInventoryAction>): Boolean {
if (!sendDirectly) {
return false
}

InventoryManager.clickOccurred()
actions.forEach { it.performAction() }
return true
}

}

0 comments on commit c26c4b0

Please sign in to comment.