/*
 * 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 tk.wurst_client.features.mods;

import net.minecraft.entity.projectile.EntityFishHook;
import tk.wurst_client.events.listeners.UpdateListener;

@Mod.Info(description = "Automatically catches fish.",
	name = "AutoFish",
	tags = "FishBot, auto fish, fish bot, fishing",
	help = "Mods/AutoFish")
@Mod.Bypasses
public class AutoFishMod extends Mod implements UpdateListener
{
	private int timer;
	
	@Override
	public void onEnable()
	{
		wurst.events.add(UpdateListener.class, this);
	}
	
	@Override
	public void onDisable()
	{
		wurst.events.remove(UpdateListener.class, this);
		timer = 0;
	}
	
	@Override
	public void onUpdate()
	{
		switch(timer)
		{
			case 0:
				EntityFishHook hook = mc.player.fishEntity;
				if(hook != null && hook.motionX == 0.0 && hook.motionZ == 0.0
					&& hook.motionY <= -0.24)
				{
					mc.rightClickMouse();
					timer = 20;
				}
				break;
			
			case 1:
				mc.rightClickMouse();
			default:
				timer--;
				break;
		}
	}
}

@@ -336,40 +336,273 @@
 aft.
-entity.projectile.EntityFishHook
+init.SoundEvents;%0Aimport net.minecraft.item.ItemFishingRod;%0Aimport net.minecraft.item.ItemStack;%0Aimport net.minecraft.network.play.server.SPacketSoundEffect;%0Aimport tk.wurst_client.events.PacketInputEvent;%0Aimport tk.wurst_client.events.listeners.PacketInputListener
 ;%0Aim
@@ -654,16 +654,61 @@
 istener;
+%0Aimport tk.wurst_client.utils.InventoryUtils;
 %0A%0A@Mod.I
@@ -900,17 +900,18 @@
 ends Mod
- 
+%0A%09
 implemen
@@ -927,16 +927,37 @@
 Listener
+, PacketInputListener
 %0A%7B%0A%09priv
@@ -1059,16 +1059,69 @@
  this);%0A
+%09%09wurst.events.add(PacketInputListener.class, this);%0A
 %09%7D%0A%09%0A%09@O
@@ -1207,16 +1207,72 @@
  this);%0A
+%09%09wurst.events.remove(PacketInputListener.class, this);%0A
 %09%09timer 
@@ -1325,20 +1325,37 @@
 %7B%0A%09%09
-switch
+// check timer%0A%09%09if
 (timer
+ %3E 0
 )%0A%09%09
@@ -1363,42 +1363,58 @@
 %0A%09%09%09
-case 0:%0A%09%09%09%09EntityFishHook hook = 
+timer--;%0A%09%09%09return;%0A%09%09%7D%0A%09%09%0A%09%09// check bobber%0A%09%09if(
 mc.p
@@ -1433,121 +1433,383 @@
 tity
+ != null)%0A%09%09%09return
 ;%0A%09%09
+%0A
 %09%09
-if(hook != null && hook.motionX == 0.0 && hook.motionZ == 0.0%0A%09%09%09%09%09&& hook.motionY %3C= -0.24)%0A%09%09%09%09%7B%0A%09%09%09%09%09mc.
+rightClick();%0A%09%7D%0A%09%0A%09@Override%0A%09public void onReceivedPacket(PacketInputEvent event)%0A%09%7B%0A%09%09// check packet type%0A%09%09if(!(event.getPacket() instanceof SPacketSoundEffect))%0A%09%09%09return;%0A%09%09%0A%09%09// check sound type%0A%09%09if(((SPacketSoundEffect)event.getPacket())%0A%09%09%09.getSound() != SoundEvents.ENTITY_BOBBER_SPLASH)%0A%09%09%09return;%0A%09%09%0A%09%09rightClick();%0A%09%7D%0A%09%0A%09private void 
 righ
@@ -1818,68 +1818,215 @@
 lick
-Mouse
 ()
-;
 %0A%09
-%09%09%09%09timer = 20;%0A%09%09%09%09%7D%0A%09%09%09%09break
+%7B%0A%09%09// check held item%0A%09%09ItemStack stack = mc.player.inventory.getCurrentItem();%0A%09%09if(InventoryUtils.isEmptySlot(stack)%0A%09%09%09%7C%7C !(stack.getItem() instanceof ItemFishingRod))%0A%09%09%09return
 ;%0A%09%09
-%09
 %0A%09%09
-%09case 1:%0A%09%09
+// right click%0A
 %09%09mc
@@ -2051,45 +2051,39 @@
 ;%0A%09%09
-%09default:%0A%09%09%09%09timer--;%0A%09%09%09%09break;%0A%09%09%7D
+%0A%09%09// reset timer%0A%09%09timer = 15;
 %0A%09%7D%0A

Fix AutoFish