/*
 * Copyright  2014 - 2016 | 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.mods;

import net.minecraft.entity.projectile.EntityFishHook;
import tk.wurst_client.events.listeners.UpdateListener;
import tk.wurst_client.mods.Mod.Bypasses;
import tk.wurst_client.mods.Mod.Info;

@Info(description = "Automatically catches fish.",
	name = "AutoFish",
	tags = "FishBot, auto fish, fish bot, fishing",
	help = "Mods/AutoFish")
@Bypasses
public class AutoFishMod extends Mod implements UpdateListener
{
	private boolean catching = false;
	
	@Override
	public void onEnable()
	{
		wurst.events.add(UpdateListener.class, this);
	}
	
	@Override
	public void onUpdate()
	{
		if(mc.player.fishEntity != null && isHooked(mc.player.fishEntity)
			&& !catching)
		{
			catching = true;
			mc.rightClickMouse();
			new Thread("AutoFish")
			{
				@Override
				public void run()
				{
					try
					{
						Thread.sleep(1000);
					}catch(InterruptedException e)
					{
						e.printStackTrace();
					}
					mc.rightClickMouse();
					catching = false;
				}
			}.start();
		}
	}
	
	@Override
	public void onDisable()
	{
		wurst.events.remove(UpdateListener.class, this);
	}
	
	private boolean isHooked(EntityFishHook hook)
	{
		return hook.motionX == 0.0 && hook.motionZ == 0.0
			&& hook.motionY <= -0.24;
	}
}

@@ -728,32 +728,17 @@
 ate 
-boolean catching = false
+int timer
 ;%0A%09%0A
@@ -872,52 +872,63 @@
 %7B%0A%09%09
-if(mc.player.fishEntity != null && 
+switch(timer)%0A%09%09%7B%0A%09%09%09case 0:%0A%09%09%09%09EntityF
 is
+h
 Hook
-ed(
+ hook = 
 mc.p
@@ -947,571 +947,361 @@
 tity
-)
+;
 %0A%09%09%09
-&& !catching)
+%09if(hook != null && hook.motionX == 0.0 && hook.motionZ == 0.0
 %0A%09%09
-%7B%0A
 %09%09%09
-catching = true;%0A%09%09%09mc.rightClickMouse();%0A%09%09%09new Thread(%22AutoFish%22)%0A%09%09%09%7B%0A%09%09%09%09@Override%0A%09%09%09%09public void run()
+&& hook.motionY %3C= -0.24)%0A%09%09%09%09%7B%0A%09%09%09%09%09mc.rightClickMouse();%0A%09%09%09%09%09timer = 20;
 %0A%09%09%09%09
-%7B
+%7D
 %0A%09%09%09%09
-%09try%0A%09%09%09%09%09%7B%0A%09%09%09%09%09%09Thread.sleep(1000);%0A%09%09%09%09%09%7Dcatch(InterruptedException e)%0A%09%09%09%09%09%7B%0A%09%09%09%09%09%09e.printStackTrace();%0A%09%09%09%09%09%7D%0A%09%09%09%09%09mc.rightClickMouse();%0A%09%09%09%09%09catching = false;%0A%09%09%09%09%7D%0A%09%09%09%7D.start();%0A%09%09%7D%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%09%0A%09private boolean isHooked(EntityFishHook hook)%0A%09%7B%0A%09%09return hook.motionX == 0.0 && hook.motionZ == 0.0%0A%09%09%09&& hook.motionY %3C= -0.24
+break;%0A%09%09%09%0A%09%09%09case 1:%0A%09%09%09%09mc.rightClickMouse();%0A%09%09%09default:%0A%09%09%09%09timer--;%0A%09%09%09%09break;%0A%09%09%7D%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%09timer = 0
 ;%0A%09%7D

Improve AutoFishMod