package com.cbouton.fatigue.handlers;

import java.util.EnumSet;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class FatigueTickHandler implements ITickHandler {

	@Override
	public String getLabel() {
		return "FatigueTickHandler";
	}

	@Override
	public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	}

	@SuppressWarnings("unused")
	@Override
	public void tickStart(EnumSet<TickType> type, Object... tickData) {
		FatiguePacketHandler handler = new FatiguePacketHandler();
		EntityPlayer player = Minecraft.getMinecraft().thePlayer;

		if (player != null) {
			if (FatigueHandler.getFatigue(player.username) <= 3000
					&& !player.capabilities.isCreativeMode) {
				player.addPotionEffect(new PotionEffect(Potion.digSlowdown
						.getId(), 2, 2));
				player.addPotionEffect(new PotionEffect(Potion.moveSlowdown
						.getId(), 2, 2));
			} else if (FatigueHandler.getFatigue(player.username) >= 54000
					&& !player.capabilities.isCreativeMode) {
				player.addPotionEffect(new PotionEffect(
						Potion.digSpeed.getId(), 2, 2));
				player.addPotionEffect(new PotionEffect(Potion.moveSpeed
						.getId(), 2, 2));
			}
		}
	}

	@Override
	public EnumSet<TickType> ticks() {
		return EnumSet.of(TickType.CLIENT);
	}

}

@@ -633,69 +633,8 @@
 ) %7B%0A
-%09%09FatiguePacketHandler handler = new FatiguePacketHandler();%0A
 %09%09En
@@ -765,17 +765,16 @@
 rname) %3C
-=
  3000%0A%09%09
@@ -889,33 +889,33 @@
 %09%09%09%09%09%09.getId(), 
-2
+1
 , 2));%0A%09%09%09%09playe
@@ -977,33 +977,33 @@
 %09%09%09%09%09%09.getId(), 
-2
+1
 , 2));%0A%09%09%09%7D else
@@ -1051,17 +1051,16 @@
 rname) %3E
-=
  54000%0A%09
@@ -1173,33 +1173,33 @@
 gSpeed.getId(), 
-2
+1
 , 2));%0A%09%09%09%09playe
@@ -1266,17 +1266,17 @@
 etId(), 
-2
+1
 , 2));%0A%09
@@ -1278,16 +1278,261 @@
 ));%0A%09%09%09%7D
+ else %7B%0A%09%09%09%09player.removePotionEffect(Potion.moveSpeed.getId());%0A%09%09%09%09player.removePotionEffect(Potion.digSpeed.getId());%0A%09%09%09%09player.removePotionEffect(Potion.moveSlowdown.getId());%0A%09%09%09%09player.removePotionEffect(Potion.digSlowdown.getId());%0A%09%09%09%7D%0A
 %0A%09%09%7D%0A%09%7D%0A

Fix effects.