mirror of https://github.com/kami-blue/client
Fixed formatting in AutoEat
This commit is contained in:
parent
8cf6d8782c
commit
7e94c12184
|
@ -23,8 +23,10 @@ import net.minecraft.util.EnumHand
|
|||
class AutoEat : Module() {
|
||||
private val foodLevel = register(Settings.integerBuilder("Below Hunger").withValue(15).withMinimum(1).withMaximum(20).build())
|
||||
private val healthLevel = register(Settings.integerBuilder("Below Health").withValue(8).withMinimum(1).withMaximum(20).build())
|
||||
|
||||
private var lastSlot = -1
|
||||
private var eating = false
|
||||
|
||||
private fun isValid(stack: ItemStack, food: Int): Boolean {
|
||||
return passItemCheck(stack.getItem()) && stack.getItem() is ItemFood && foodLevel.value - food >= (stack.getItem() as ItemFood).getHealAmount(stack) ||
|
||||
passItemCheck(stack.getItem()) && stack.getItem() is ItemFood && healthLevel.value - (mc.player.health + mc.player.absorptionAmount) > 0f
|
||||
|
@ -39,20 +41,26 @@ class AutoEat : Module() {
|
|||
|
||||
override fun onUpdate() {
|
||||
if (mc.player == null) return
|
||||
|
||||
if (eating && !mc.player.isHandActive) {
|
||||
if (lastSlot != -1) {
|
||||
mc.player.inventory.currentItem = lastSlot
|
||||
lastSlot = -1
|
||||
}
|
||||
eating = false
|
||||
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.keyCode, false)
|
||||
return
|
||||
}
|
||||
|
||||
if (eating) return
|
||||
|
||||
val stats = mc.player.getFoodStats()
|
||||
|
||||
if (isValid(mc.player.heldItemOffhand, stats.foodLevel)) {
|
||||
mc.player.activeHand = EnumHand.OFF_HAND
|
||||
eating = true
|
||||
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.keyCode, true)
|
||||
mc.playerController.processRightClick(mc.player, mc.world, EnumHand.OFF_HAND)
|
||||
} else {
|
||||
|
@ -61,6 +69,7 @@ class AutoEat : Module() {
|
|||
lastSlot = mc.player.inventory.currentItem
|
||||
mc.player.inventory.currentItem = i
|
||||
eating = true
|
||||
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.keyCode, true)
|
||||
mc.playerController.processRightClick(mc.player, mc.world, EnumHand.MAIN_HAND)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue