/*
 * 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.client.entity.EntityPlayerSP;
import net.minecraft.init.MobEffects;
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 = "Blocks bad potion effects.",
	name = "AntiPotion",
	tags = "NoPotion, Zoot, anti potions, no potions",
	help = "Mods/AntiPotion")
@Mod.Bypasses(ghostMode = false, latestNCP = false, olderNCP = false)
public final class AntiPotionMod extends Mod implements UpdateListener
{
	@Override
	public void onEnable()
	{
		wurst.events.add(UpdateListener.class, this);
	}
	
	@Override
	public void onUpdate()
	{
		EntityPlayerSP player = WMinecraft.getPlayer();
		if(!player.capabilities.isCreativeMode && player.onGround
			&& !player.getActivePotionEffects().isEmpty())
			if(player.isPotionActive(MobEffects.hunger)
				|| player.isPotionActive(MobEffects.moveSlowdown)
				|| player.isPotionActive(MobEffects.digSlowdown)
				|| player.isPotionActive(MobEffects.harm)
				|| player.isPotionActive(MobEffects.confusion)
				|| player.isPotionActive(MobEffects.blindness)
				|| player.isPotionActive(MobEffects.weakness)
				|| player.isPotionActive(MobEffects.wither)
				|| player.isPotionActive(MobEffects.poison))
				for(int i = 0; i < 1000; i++)
					WConnection.sendPacket(new CPacketPlayer());
	}
	
	@Override
	public void onDisable()
	{
		wurst.events.remove(UpdateListener.class, this);
	}
}

@@ -315,59 +315,8 @@
 s;%0A%0A
-import net.minecraft.client.entity.EntityPlayerSP;%0A
 impo
@@ -405,16 +405,52 @@
 Player;%0A
+import net.minecraft.potion.Potion;%0A
 import n
@@ -895,16 +895,267 @@
 tener%0A%7B%0A
+%09private final Potion%5B%5D blockedEffects = new Potion%5B%5D%7BMobEffects.hunger,%0A%09%09MobEffects.moveSlowdown, MobEffects.digSlowdown, MobEffects.harm,%0A%09%09MobEffects.confusion, MobEffects.blindness, MobEffects.weakness,%0A%09%09MobEffects.wither, MobEffects.poison%7D;%0A%09%0A
 %09@Overri
@@ -1263,21 +1263,22 @@
  void on
-Updat
+Disabl
 e()%0A%09%7B%0A%09
@@ -1282,32 +1282,125 @@
 %7B%0A%09%09
-EntityPlayerSP player = 
+wurst.events.remove(UpdateListener.class, this);%0A%09%7D%0A%09%0A%09@Override%0A%09public void onUpdate()%0A%09%7B%0A%09%09// check gamemode%0A%09%09if(
 WMin
@@ -1421,22 +1421,8 @@
 er()
-;%0A%09%09if(!player
 .cap
@@ -1449,531 +1449,172 @@
 Mode
- && player.onGround%0A%09%09%09&& !player.getActivePotionEffects().isEmpty())%0A%09%09%09if(player.isPotionActive(MobEffects.hunger)%0A%09%09%09%09%7C%7C player.isPotionActive(MobEffects.moveSlowdown)%0A%09%09%09%09%7C%7C player.isPotionActive(MobEffects.digSlowdown)%0A%09%09%09%09%7C%7C player.isPotionActive(MobEffects.harm)
+)%0A%09%09%09return;%0A%09%09%0A%09%09// check onGround%0A%09%09if(!WMinecraft.getPlayer().onGround)%0A%09%09%09return;
 %0A%09%09
+%0A
 %09%09
-%7C%7C player.isPotionActive(MobEffects.confusion)%0A%09%09%09%09%7C%7C player.isPotionActive(MobEffects.blindness)%0A%09%09%09%09%7C%7C player.isPotionActive(MobEffects.weakness)
+// check effects%0A%09%09if(!hasBadEffect())%0A%09%09%09return;
 %0A%09%09
+%0A
 %09%09
-%7C%7C player.isPotionActive(MobEffects.wither)%0A%09%09%09%09%7C%7C player.isPotionActive(MobEffects.poison))%0A%09
+// send packets%0A
 %09%09
-%09
 for(
@@ -1639,18 +1639,16 @@
 0; i++)%0A
-%09%09
 %09%09%09WConn
@@ -1697,95 +1697,252 @@
 %0A%09%0A%09
-@Override%0A%09public void onDisable()%0A%09%7B%0A%09%09wurst.events.remove(UpdateListener.class, this)
+private boolean hasBadEffect()%0A%09%7B%0A%09%09if(WMinecraft.getPlayer().getActivePotionEffects().isEmpty())%0A%09%09%09return false;%0A%09%09%0A%09%09for(Potion effect : blockedEffects)%0A%09%09%09if(WMinecraft.getPlayer().isPotionActive(effect))%0A%09%09%09%09return true;%0A%09%09%09%0A%09%09return false
 ;%0A%09%7D

Update AntiPotionMod