/*
 * 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.ItemBow;
import net.minecraft.network.play.client.CPacketPlayer;
import net.minecraft.network.play.client.CPacketPlayerDigging;
import net.minecraft.network.play.client.CPacketPlayerDigging.Action;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.wurstclient.compatibility.WConnection;
import net.wurstclient.compatibility.WMinecraft;
import net.wurstclient.compatibility.WPlayerController;
import net.wurstclient.events.listeners.UpdateListener;
import net.wurstclient.features.Feature;

@Mod.Info(
	description = "Turns your bow into a machine gun.\n"
		+ "Tip: This works with BowAimbot.",
	name = "FastBow",
	tags = "RapidFire, BowSpam, fast bow, rapid fire, bow spam",
	help = "Mods/FastBow")
@Mod.Bypasses(ghostMode = false, latestNCP = false, olderNCP = false)
public final class FastBowMod extends Mod implements UpdateListener
{
	@Override
	public Feature[] getSeeAlso()
	{
		return new Feature[]{wurst.mods.bowAimbotMod};
	}
	
	@Override
	public void onEnable()
	{
		wurst.events.add(UpdateListener.class, this);
	}
	
	@Override
	public void onUpdate()
	{
		if(WMinecraft.getPlayer().getHealth() > 0
			&& (WMinecraft.getPlayer().onGround
				|| WMinecraft.getPlayer().capabilities.isCreativeMode)
			&& WMinecraft.getPlayer().inventory.getCurrentItem() != null
			&& WMinecraft.getPlayer().inventory.getCurrentItem()
				.getItem() instanceof ItemBow
			&& mc.gameSettings.keyBindUseItem.pressed)
		{
			WPlayerController.processRightClick();
			WMinecraft.getPlayer().inventory.getCurrentItem().getItem()
				.onItemRightClick(
					WMinecraft.getPlayer().inventory.getCurrentItem(),
					WMinecraft.getWorld(), WMinecraft.getPlayer(),
					EnumHand.MAIN_HAND);
			for(int i = 0; i < 20; i++)
				WConnection.sendPacket(new CPacketPlayer(false));
			WConnection
				.sendPacket(new CPacketPlayerDigging(Action.RELEASE_USE_ITEM,
					new BlockPos(0, 0, 0), EnumFacing.DOWN));
			WMinecraft.getPlayer().inventory.getCurrentItem().getItem()
				.onPlayerStoppedUsing(
					WMinecraft.getPlayer().inventory.getCurrentItem(),
					WMinecraft.getWorld(), WMinecraft.getPlayer(), 10);
		}
	}
	
	@Override
	public void onDisable()
	{
		wurst.events.remove(UpdateListener.class, this);
	}
}

@@ -371,289 +371,78 @@
 aft.
-network.play.client.CPacketPlayer;%0Aimport net.minecraft.network.play.client.CPacketPlayerDigging;%0Aimport net.minecraft.network.play.client.CPacketPlayerDigging.Action;%0Aimport net.minecraft.util.EnumFacing;%0Aimport net.minecraft.util.EnumHand;%0Aimport net.minecraft.util.math.BlockPos
+item.ItemStack;%0Aimport net.minecraft.network.play.client.CPacketPlayer
 ;%0Aim
@@ -690,16 +690,61 @@
 Feature;
+%0Aimport net.wurstclient.utils.InventoryUtils;
 %0A%0A@Mod.I
@@ -1320,57 +1320,121 @@
 %7B%0A%09%09
-if(WMinecraft.getPlayer().getHealth() %3E 0%0A%09%09%09&& (
+// check if right-clicking%0A%09%09if(!mc.gameSettings.keyBindUseItem.pressed)%0A%09%09%09return;%0A%09%09%0A%09%09// check fly-kick%0A%09%09if(!
 WMin
@@ -1468,12 +1468,12 @@
 %0A%09%09%09
-%09%7C%7C 
+&& !
 WMin
@@ -1527,74 +1527,137 @@
 %0A%09%09%09
-&& WMinecraft.getPlayer().inventory.getCurrentItem() != null%0A%09%09%09&&
+return;%0A%09%09%0A%09%09// check health%0A%09%09if(WMinecraft.getPlayer().getHealth() %3C= 0)%0A%09%09%09return;%0A%09%09%0A%09%09// check held item%0A%09%09ItemStack stack =
  WMi
@@ -1702,21 +1702,70 @@
 ntItem()
+;
 %0A%09%09
-%09%09
+if(InventoryUtils.isEmptySlot(stack)%0A%09%09%09%7C%7C !(stack
 .getItem
@@ -1789,60 +1789,25 @@
 mBow
+))
 %0A%09%09%09
-&& mc.gameSettings.keyBindUseItem.pressed)%0A%09%09%7B%0A%09
+return;%0A%09%09%0A
 %09%09WP
@@ -1849,227 +1849,9 @@
 ;%0A%09%09
-%09WMinecraft.getPlayer().inventory.getCurrentItem().getItem()%0A%09%09%09%09.onItemRightClick(%0A%09%09%09%09%09WMinecraft.getPlayer().inventory.getCurrentItem(),%0A%09%09%09%09%09WMinecraft.getWorld(), WMinecraft.getPlayer(),%0A%09%09%09%09%09EnumHand.MAIN_HAND);%0A%09
+%0A
 %09%09fo
@@ -1876,17 +1876,16 @@
 0; i++)%0A
-%09
 %09%09%09WConn
@@ -1935,308 +1935,50 @@
 ;%0A%09%09
-%09WConnection%0A%09%09%09%09.sendPacket(new CPacketPlayerDigging(Action.RELEASE_USE_ITEM,%0A%09%09%09%09%09new BlockPos(0, 0, 0), EnumFacing.DOWN));%0A%09%09%09WMinecraft.getPlayer().inventory.getCurrentItem().getItem()%0A%09%09%09%09.onPlayerStoppedUsing(%0A%09%09%09%09%09WMinecraft.getPlayer().inventory.getCurrentItem(),%0A%09%09%09%09%09WMinecraft.getWorld(), 
+%0A%09%09mc.playerController.onStoppedUsingItem(
 WMin
@@ -1999,18 +1999,10 @@
 er()
-, 10);%0A%09%09%7D
+);
 %0A%09%7D%0A

Update FastBowMod