package tamaized.aov.common.events;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
import tamaized.aov.common.capabilities.CapabilityList;
import tamaized.aov.common.capabilities.aov.IAoVCapability;
import tamaized.aov.common.capabilities.astro.IAstroCapability;
import tamaized.aov.common.capabilities.stun.IStunCapability;
import tamaized.aov.registry.AoVPotions;

public class TickHandler {

	@SubscribeEvent
	public void update(PlayerTickEvent e) {
		if (e.phase == TickEvent.Phase.START)
			return;
		EntityPlayer player = e.player;
		if (player.getHealth() <= (player.getMaxHealth() / 2) && player.getActivePotionEffect(AoVPotions.stalwartPact) != null) {
			player.removeActivePotionEffect(AoVPotions.stalwartPact);
			player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, (20 * (60 * 5)), 2));
			player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, (20 * (10)), 2));
		}
		if (player.hasCapability(CapabilityList.AOV, null)) {
			IAoVCapability cap = player.getCapability(CapabilityList.AOV, null);
			if (cap != null)
				cap.update(player);
		}
		if (player.hasCapability(CapabilityList.ASTRO, null)) {
			IAstroCapability cap = player.getCapability(CapabilityList.ASTRO, null);
			if (cap != null)
				cap.update(player);
		}
	}

	@SubscribeEvent
	public void updateEntity(LivingEvent.LivingUpdateEvent e) {
		EntityLivingBase entity = e.getEntityLiving();
		IStunCapability cap = entity.hasCapability(CapabilityList.STUN, null) ? entity.getCapability(CapabilityList.STUN, null) : null;
		if (cap != null)
			cap.update(entity);
	}

}

@@ -30,16 +30,52 @@
 vents;%0A%0A
+import net.minecraft.entity.Entity;%0A
 import n
@@ -245,67 +245,8 @@
 ct;%0A
-import net.minecraftforge.event.entity.living.LivingEvent;%0A
 impo
@@ -1666,69 +1666,110 @@
 ity(
-LivingEvent.LivingUpdateEvent e) %7B%0A%09%09EntityLivingBase
+TickEvent.WorldTickEvent e) %7B%0A%09%09if (e.phase == TickEvent.Phase.START)%0A%09%09%09return;%0A%09%09for (Entity
  entity 
 = e.
@@ -1768,31 +1768,99 @@
 ity 
-= e.getEntityLiving()
+: e.world.loadedEntityList) %7B%0A%09%09%09if (!(entity instanceof EntityLivingBase))%0A%09%09%09%09continue
 ;%0A
+%09
 %09%09IS
@@ -1983,24 +1983,25 @@
 ) : null;%0A%09%09
+%09
 if (cap != n
@@ -2008,16 +2008,17 @@
 ull)%0A%09%09%09
+%09
 cap.upda
@@ -2020,16 +2020,35 @@
 .update(
+(EntityLivingBase) 
 entity);
@@ -2048,14 +2048,18 @@
 ntity);%0A
+%09%09%7D%0A
 %09%7D%0A%0A%7D%0A

Revert 3ad07dd041c8e060cf27f4e8230cd5fa52bdb7ad