Skip to content

Commit 7f58d84

Browse files
committed
always, and ignoreWhenHolding setting in auto totem
1 parent 9b034a6 commit 7f58d84

File tree

1 file changed

+12
-11
lines changed
  • src/main/kotlin/com/lambda/module/modules/combat

1 file changed

+12
-11
lines changed

src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,24 @@ object AutoTotem : Module(
4545
tag = ModuleTag.COMBAT,
4646
) {
4747
private val log by setting("Log Message", true).group(Group.General)
48-
49-
private val minimumHealth by setting("Min Health", 10, 6..36, 1, "Set the minimum health threshold to swap", unit = " half-hearts").group(Group.General)
50-
private val falls by setting("Falls", true, "Swap if the player will die of fall damage").group(Group.General)
51-
private val fallDistance by setting("Falls Time", 10, 0..30, 1, "Number of blocks fallen before swapping", unit = " blocks") { falls }.group(Group.General)
52-
private val crystals by setting("Crystals", true, "Swap if an End Crystal explosion would be lethal").group(Group.General)
53-
private val creeper by setting("Creepers", true, "Swap when an ignited Creeper is nearby").group(Group.General)
54-
private val players by setting("Players", false, "Swap if a nearby player is detected within the set distance").group(Group.General)
55-
private val minPlayerDistance by setting("Player Distance", 64, 32..128, 4, "Set the distance to detect players to swap") { players }.group(Group.General)
56-
private val friends by setting("Friends", false, "Exclude friends from triggering player-based swaps") { players }.group(Group.General)
48+
private val always by setting("Always", true, "Always attempt to keep a totem in offhand").group(Group.General)
49+
private val ignoreWhenHolding by setting("Ignore When Holding", false, "Ignore swapping to offhand when already holding a totem").group(Group.General)
50+
private val minimumHealth by setting("Min Health", 10, 6..36, 1, "Set the minimum health threshold to swap", unit = " half-hearts") { !always }.group(Group.General)
51+
private val falls by setting("Falls", true, "Swap if the player will die of fall damage") { !always }.group(Group.General)
52+
private val fallDistance by setting("Falls Time", 10, 0..30, 1, "Number of blocks fallen before swapping", unit = " blocks") { !always && falls }.group(Group.General)
53+
private val crystals by setting("Crystals", true, "Swap if an End Crystal explosion would be lethal") { !always }.group(Group.General)
54+
private val creeper by setting("Creepers", true, "Swap when an ignited Creeper is nearby") { !always }.group(Group.General)
55+
private val players by setting("Players", false, "Swap if a nearby player is detected within the set distance") { !always }.group(Group.General)
56+
private val minPlayerDistance by setting("Player Distance", 64, 32..128, 4, "Set the distance to detect players to swap") { !always && players }.group(Group.General)
57+
private val friends by setting("Friends", false, "Exclude friends from triggering player-based swaps") { !always && players }.group(Group.General)
5758

5859
override val inventoryConfig = InventorySettings(this, Group.Inventory)
5960

6061
init {
6162
listen<TickEvent.Pre> {
62-
if (Reason.entries.none { it.check(this) }) return@listen
63+
if (!always && Reason.entries.none { it.check(this) }) return@listen
6364

64-
if (!player.isHolding(Items.TOTEM_OF_UNDYING)) {
65+
if ((!ignoreWhenHolding || !player.isHolding(Items.TOTEM_OF_UNDYING)) && player.offHandStack.item != Items.TOTEM_OF_UNDYING) {
6566
Items.TOTEM_OF_UNDYING.select()
6667
.transfer(OffHandContainer)
6768
?.finally { if (log) info("Swapped the off-hand item with a totem") }

0 commit comments

Comments
 (0)