/*
 * Copyright  2014 - 2017 | Wurst-Imperium | All rights reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package net.wurstclient.features.mods;

import net.minecraft.item.ItemFood;
import net.minecraft.network.play.client.CPacketPlayer;
import net.wurstclient.compatibility.WConnection;
import net.wurstclient.compatibility.WMinecraft;
import net.wurstclient.events.listeners.UpdateListener;

@Mod.Info(
	description = "Allows you to eat food much faster.\n" + "OM! NOM! NOM!",
	name = "FastEat",
	tags = "FastNom, fast eat, fast nom",
	help = "Mods/FastEat")
@Mod.Bypasses(ghostMode = false, latestNCP = false, olderNCP = false)
public final class FastEatMod extends Mod implements UpdateListener
{
	@Override
	public void onEnable()
	{
		wurst.events.add(UpdateListener.class, this);
	}
	
	@Override
	public void onUpdate()
	{
		if(WMinecraft.getPlayer().getHealth() > 0
			&& WMinecraft.getPlayer().onGround
			&& WMinecraft.getPlayer().inventory.getCurrentItem() != null
			&& WMinecraft.getPlayer().inventory.getCurrentItem()
				.getItem() instanceof ItemFood
			&& WMinecraft.getPlayer().getFoodStats().needFood()
			&& mc.gameSettings.keyBindUseItem.pressed)
			for(int i = 0; i < 100; i++)
				WConnection.sendPacket(new CPacketPlayer(false));
	}
	
	@Override
	public void onDisable()
	{
		wurst.events.remove(UpdateListener.class, this);
	}
}

@@ -557,16 +557,61 @@
 istener;
+%0Aimport net.wurstclient.utils.InventoryUtils;
 %0A%0A@Mod.I
@@ -1032,19 +1032,134 @@
 d on
-Update()%0A%09%7B
+Disable()%0A%09%7B%0A%09%09wurst.events.remove(UpdateListener.class, this);%0A%09%7D%0A%09%0A%09@Override%0A%09public void onUpdate()%0A%09%7B%0A%09%09// check if alive
 %0A%09%09i
@@ -1199,41 +1199,39 @@
 h() 
-%3E
+%3C=
  0
+)
 %0A%09%09%09
-&& WMinecraft.getPlayer().
+return;%0A%09%09%0A%09%09// check 
 onGr
@@ -1233,28 +1233,28 @@
  onGround%0A%09%09
-%09&& 
+if(!
 WMinecraft.g
@@ -1268,140 +1268,143 @@
 r().
-inventory.g
+onGround)%0A%09%09%09r
 et
-C
 ur
-rentItem() != null%0A%09%09%09&& WMinecraft.getPlayer().inventory.g
+n;%0A%09%09%0A%09%09// check if eating%0A%09%09if(!mc.gameSettings.keyBindUseItem.pressed)%0A%09%09%09r
 et
-C
 ur
-rentItem()
+n;
 %0A%09%09
+%0A
 %09%09
-.getItem() instanceof ItemFood%0A%09%09%09&& 
+// check hunger level%0A%09%09if(!
 WMin
@@ -1451,56 +1451,149 @@
 od()
+)
 %0A%09%09%09
-&& mc.gameSettings.keyBindUseItem.pressed)%0A%09
+return;%0A%09%09%0A%09%09// check held item%0A%09%09if(!InventoryUtils.checkHeldItem((item) -%3E item instanceof ItemFood))%0A%09%09%09return;%0A%09%09%0A%09%09// send packets%0A
 %09%09fo
@@ -1619,17 +1619,16 @@
 0; i++)%0A
-%09
 %09%09%09WConn
@@ -1679,101 +1679,6 @@
 %0A%09%7D%0A
-%09%0A%09@Override%0A%09public void onDisable()%0A%09%7B%0A%09%09wurst.events.remove(UpdateListener.class, this);%0A%09%7D%0A
 %7D%0A

Update FastEatMod