Skip to content

Commit 9d2dc38

Browse files
committed
min armor durability
1 parent c1cf3a5 commit 9d2dc38

File tree

1 file changed

+6
-2
lines changed
  • src/main/kotlin/com/lambda/module/modules/player

1 file changed

+6
-2
lines changed

src/main/kotlin/com/lambda/module/modules/player/AutoArmor.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ object AutoArmor : Module(
4949
) {
5050
private var elytraPriority by setting("Elytra Priority", true, "Prioritizes elytra's over other armor pieces in the chest slot")
5151
private val toggleElytraPriority by setting("Toggle Elytra Priority", Bind.EMPTY)
52+
private val minDurabilityPercentage by setting("Min Durability Percentage", 5, 0..100, 1, "Minimum durability percentage before being swapped for a new piece")
5253
private val headProtection by setting("Preferred Head Protection", Protection.Protection)
5354
private val chestProtection by setting("Preferred Chest Protection", Protection.Protection)
5455
private val legProtection by setting("Preferred Leg Protection", Protection.BlastProtection)
@@ -66,10 +67,13 @@ object AutoArmor : Module(
6667
val armorSlots = player.armorSlots
6768

6869
val sorter = compareByDescending<Slot> {
69-
if (elytraPriority) {
70+
if (it.stack.damage.toFloat() / it.stack.maxDamage < 1 - (minDurabilityPercentage.toFloat() / 100)) Double.MIN_VALUE
71+
else if (elytraPriority) {
7072
if (it.stack.item == Items.ELYTRA) 1.0
7173
else 0.0
72-
} else it.stack.getOrDefault(DataComponentTypes.ATTRIBUTE_MODIFIERS, null)
74+
} else 0.0
75+
}.thenByDescending {
76+
it.stack.getOrDefault(DataComponentTypes.ATTRIBUTE_MODIFIERS, null)
7377
?.modifiers
7478
?.find { modifier -> modifier.attribute == EntityAttributes.ARMOR }
7579
?.modifier?.value

0 commit comments

Comments
 (0)