Skip to content

Commit c1cf3a5

Browse files
committed
distinct by armor slot
1 parent eca598c commit c1cf3a5

File tree

1 file changed

+5
-1
lines changed
  • src/main/kotlin/com/lambda/module/modules/player

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ object AutoArmor : Module(
100100
val swappable = player.hotbarAndInventorySlots
101101
.filter { it.stack.isEquipable && (!ignoreBinding || it.stack.getEnchantment(Enchantments.BINDING_CURSE) <= 0) }
102102
.sortedWith(sorter)
103-
.distinctBy { it.stack.item }
103+
.distinctBy { it.stack.armorSlot }
104104

105105
val swaps = mutableListOf<Pair<Slot, Slot>>()
106106
armorSlots.forEach { equipped ->
@@ -130,6 +130,10 @@ object AutoArmor : Module(
130130
private val ItemStack.isEquipable get() =
131131
safeContext.player.armorSlots.any { it.canInsert(this) }
132132

133+
context(safeContext: SafeContext)
134+
private val ItemStack.armorSlot get() =
135+
safeContext.player.armorSlots.firstOrNull { it.canInsert(this) }
136+
133137
private enum class Protection(val enchant: RegistryKey<Enchantment>) {
134138
Protection(Enchantments.PROTECTION),
135139
BlastProtection(Enchantments.BLAST_PROTECTION),

0 commit comments

Comments
 (0)