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

56 lines
1.8 KiB
Java
Raw Normal View History

package biomesoplenty.potions;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
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;
}
}
if (event.entityLiving.isPotionActive(Potions.paralysis.get()))
{
event.entityLiving.motionX = 0.0;
if (!event.entityLiving.isAirBorne)
event.entityLiving.motionY = 0.0;
event.entityLiving.motionZ = 0.0;
if (event.entityLiving instanceof EntityCreeper)
((EntityCreeper)event.entityLiving).setCreeperState(-1);
if (event.entityLiving.getActivePotionEffect(Potions.paralysis.get()).getDuration() == 0)
{
event.entityLiving.removePotionEffect(Potions.paralysis.get().id);
return;
}
}
}
@ForgeSubscribe
public void onEndermanTP(EnderTeleportEvent event)
{
if (event.entityLiving.isPotionActive(Potions.paralysis.get()))
event.setCanceled(true);
}
}