Skip to content

Commit

Permalink
AutoEat now works with chat open
Browse files Browse the repository at this point in the history
  • Loading branch information
fr1kin committed Aug 22, 2017
1 parent e6f1be9 commit c93f50a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/java/com/matt/forgehax/mods/AutoEatMod.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.matt.forgehax.mods;

import com.matt.forgehax.asm.reflection.FastReflection;
import com.matt.forgehax.events.LocalPlayerUpdateEvent;
import com.matt.forgehax.util.key.Bindings;
import com.matt.forgehax.util.mod.ToggleMod;
Expand All @@ -9,7 +10,7 @@
import net.minecraft.util.FoodStats;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import static com.matt.forgehax.Helper.*;
import static com.matt.forgehax.Helper.getLocalPlayer;

@RegisterMod
public class AutoEatMod extends ToggleMod {
Expand All @@ -35,16 +36,20 @@ public void onUpdate(LocalPlayerUpdateEvent event) {
}
if (foodStack != null) {
ItemFood itemFood = (ItemFood) foodStack.getItem();
if (20 - foodStats.getFoodLevel() >= itemFood.getHealAmount(foodStack)) {
if (20 - foodStats.getFoodLevel() >= itemFood.getHealAmount(foodStack)
&& !getLocalPlayer().isHandActive()
&& FastReflection.Fields.Minecraft_rightClickDelayTimer.get(MC) == 0) {
isEating = true;
MC.player.inventory.currentItem = foodSlot;
// need to fake use key to stop code that stops the eating
Bindings.use.setPressed(true);
FastReflection.Methods.Minecraft_rightClickMouse.invoke(MC);
return;
}
}
if(isEating) {
Bindings.use.setPressed(false);
if(isEating && !getLocalPlayer().isHandActive()) {
isEating = false;
Bindings.use.setPressed(false);
}
}
}

0 comments on commit c93f50a

Please sign in to comment.