Add AutoEat
This commit is contained in:
parent
3975552eeb
commit
4bc16cd942
4 changed files with 76 additions and 1 deletions
|
@ -17,6 +17,7 @@ import com.baseband.client.module.movement.ElytraFly;
|
|||
import com.baseband.client.module.movement.NoSlowDown;
|
||||
import com.baseband.client.module.movement.Velocity;
|
||||
import com.baseband.client.module.render.*;
|
||||
import com.baseband.client.module.world.AutoEat;
|
||||
import com.baseband.client.module.world.AutoSignText;
|
||||
import com.baseband.client.module.world.Selection;
|
||||
|
||||
|
@ -59,6 +60,7 @@ public class Setup {
|
|||
new ElytraBot(),
|
||||
new ChatFilter(),
|
||||
new Baritone(),
|
||||
new AutoEat()
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -4,9 +4,13 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.util.Timer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public interface IMinecraft {
|
||||
@Accessor("timer")
|
||||
Timer getTimer();
|
||||
|
||||
@Invoker("rightClickMouse")
|
||||
void rightClick();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ public enum Category {
|
|||
COMBAT("Combat", Combat.class),
|
||||
MOVEMENT("Movement", Movement.class),
|
||||
WORLD("World", World.class)
|
||||
|
||||
;
|
||||
|
||||
Category(String name, Class<? extends Annotation> annotationClass) {
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package com.baseband.client.module.world;
|
||||
|
||||
import com.baseband.client.event.events.BaritoneEvent;
|
||||
import com.baseband.client.mixins.IMinecraft;
|
||||
import com.baseband.client.module.Feature;
|
||||
import com.baseband.client.module.category.World;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.item.ItemAppleGold;
|
||||
import net.minecraft.item.ItemChorusFruit;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.FoodStats;
|
||||
|
||||
@World
|
||||
public class AutoEat extends Feature {
|
||||
|
||||
private int lastSlot = -1;
|
||||
private boolean eating = false;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutoEat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
if (eating && !mc.player.isHandActive()) {
|
||||
if (lastSlot != -1) {
|
||||
mc.player.inventory.currentItem = lastSlot;
|
||||
lastSlot = -1;
|
||||
}
|
||||
eating = false;
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false);
|
||||
return;
|
||||
}
|
||||
if (eating) return;
|
||||
|
||||
FoodStats stats = mc.player.getFoodStats();
|
||||
if (isValid(mc.player.getHeldItemOffhand(), stats.getFoodLevel())) {
|
||||
mc.player.setActiveHand(EnumHand.OFF_HAND);
|
||||
eating = true;
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), true);
|
||||
((IMinecraft) mc).rightClick();
|
||||
} else {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (isValid(mc.player.inventory.getStackInSlot(i), stats.getFoodLevel())) {
|
||||
lastSlot = mc.player.inventory.currentItem;
|
||||
mc.player.inventory.currentItem = i;
|
||||
eating = true;
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), true);
|
||||
((IMinecraft) mc).rightClick();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void baritone(BaritoneEvent e) {
|
||||
if(!e.isCancelled()) {
|
||||
e.setCancelled(eating);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean isValid(ItemStack stack, int food) {
|
||||
return stack.getItem() instanceof ItemFood && !(stack.getItem() instanceof ItemChorusFruit) && ((20 - food)>=((ItemFood) stack.getItem()).getHealAmount(stack) || (stack.getItem() instanceof ItemAppleGold && mc.player.getHealth() < 20f));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue