Skip to content

Commit 7aa5375

Browse files
committed
AntiAFK: Add "helpMend" setting
This setting helps you mend items while being AFK (made thinking about AFK fishing) by replacing the offhand item with low HP items of the same type that have the mending enchantment.
1 parent b252f97 commit 7aa5375

File tree

1 file changed

+15
-0
lines changed
  • src/main/kotlin/com/lambda/client/module/modules/misc

1 file changed

+15
-0
lines changed

src/main/kotlin/com/lambda/client/module/modules/misc/AntiAFK.kt

+15
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ import com.lambda.client.util.BaritoneUtils
1212
import com.lambda.client.util.MovementUtils.realSpeed
1313
import com.lambda.client.util.TickTimer
1414
import com.lambda.client.util.TimeUnit
15+
import com.lambda.client.util.items.inventorySlots
16+
import com.lambda.client.util.items.moveToSlot
17+
import com.lambda.client.util.items.offhandSlot
1518
import com.lambda.client.util.text.MessageDetection
19+
import com.lambda.client.util.text.MessageSendHelper
1620
import com.lambda.client.util.text.MessageSendHelper.sendServerMessage
1721
import com.lambda.client.util.threads.safeListener
22+
import net.minecraft.enchantment.EnchantmentHelper
23+
import net.minecraft.init.Enchantments
1824
import net.minecraft.network.play.server.SPacketChat
1925
import net.minecraft.util.EnumHand
2026
import net.minecraft.util.math.BlockPos
@@ -42,6 +48,7 @@ object AntiAFK : Module(
4248
private val radius by setting("Radius", 64, 8..128, 8, fineStep = 1)
4349
private val inputTimeout by setting("Idle Timeout", 0, 0..15, 1, description = "Starts AntiAFK after being idle longer than the selected time in minutes, 0 to disable", unit = "m")
4450
private val allowBreak by setting("Allow Breaking Blocks", false, { walk.value })
51+
private val helpMend by setting("Help Mend", false, description = "Helps mending items by replacing the offhand item with low HP items of the same type")
4552

4653
private var startPos: BlockPos? = null
4754
private var squareStep = 0
@@ -123,6 +130,14 @@ object AntiAFK : Module(
123130
safeListener<TickEvent.ClientTickEvent> {
124131
if (it.phase != TickEvent.Phase.END) return@safeListener
125132

133+
if (helpMend && (player.heldItemOffhand.itemDamage == 0 || EnchantmentHelper.getEnchantmentLevel(Enchantments.MENDING, player.heldItemOffhand) == 0)) {
134+
val chosenItemSlots = player.inventorySlots.filter{it.stack.item.equals(player.heldItemOffhand.item) && EnchantmentHelper.getEnchantmentLevel(Enchantments.MENDING, it.stack) != 0 && it.stack.itemDamage != 0}
135+
if (chosenItemSlots.isNotEmpty()) {
136+
MessageSendHelper.sendChatMessage("$chatName Switching offhand to another item as it has max HP (Help Mend).")
137+
moveToSlot(this@AntiAFK, chosenItemSlots[0], player.offhandSlot)
138+
}
139+
}
140+
126141
if (inputTimeout > 0) {
127142
if ((startPos == null || !BaritoneUtils.isPathing) && player.realSpeed > 0.2) {
128143
inputTimer.reset()

0 commit comments

Comments
 (0)