BiomesOPlenty/src/minecraft/biomesoplenty/potions/PotionEventHandler.java

30 lines
870 B
Java
Raw Normal View History

package biomesoplenty.potions;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
2013-05-25 09:33:37 +00:00
import biomesoplenty.api.Potions;
public class PotionEventHandler
{
@ForgeSubscribe
public void onEntityUpdate(LivingUpdateEvent event)
{
2013-05-25 09:33:37 +00:00
if (event.entityLiving.isPotionActive(Potions.nourishment.get()))
{
2013-05-25 09:33:37 +00:00
if (event.entityLiving.worldObj.rand.nextInt(150) == 0)
{
if (!event.entityLiving.worldObj.isRemote)
if (event.entityLiving instanceof EntityPlayer)
((EntityPlayer)event.entityLiving).getFoodStats().addStats(1, 0);
}
2013-05-25 09:33:37 +00:00
if (event.entityLiving.getActivePotionEffect(Potions.nourishment.get()).getDuration() == 0)
{
2013-05-25 09:33:37 +00:00
event.entityLiving.removePotionEffect(Potions.nourishment.get().id);
return;
}
}
}
}