Created
August 11, 2017 07:52
-
-
Save Brogolem35/76738b6f1fec3c327d7178d5db9efb59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.brogolem35.BetterCraft.handler; | |
import com.brogolem35.BetterCraft.potion.ModPotionEffects; | |
import net.minecraft.entity.Entity; | |
import net.minecraft.entity.EntityLivingBase; | |
import net.minecraft.entity.SharedMonsterAttributes; | |
import net.minecraft.init.MobEffects; | |
import net.minecraft.util.DamageSource; | |
import net.minecraftforge.event.entity.living.LivingEvent; | |
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; | |
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; | |
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | |
public class PotionEvent { | |
@SubscribeEvent | |
public void onEntityUpdate(LivingUpdateEvent e, LivingJumpEvent ej){ | |
if(e.getEntityLiving().isPotionActive(ModPotionEffects.FROSTBURN)){ | |
if(e.getEntityLiving().getActivePotionEffect(ModPotionEffects.FROSTBURN).getDuration() == 0){ | |
e.getEntityLiving().removePotionEffect(ModPotionEffects.FROSTBURN); | |
return; | |
} | |
else if(e.getEntityLiving().world.rand.nextInt(30) == 0){ | |
e.getEntityLiving().attackEntityFrom(DamageSource.MAGIC, 1); | |
} | |
} | |
if(e.getEntityLiving().isPotionActive(ModPotionEffects.LIQUIDFIRE)){ | |
e.getEntityLiving().setFire(6); | |
} | |
if (e.getEntityLiving().isPotionActive(ModPotionEffects.ROOT)) | |
{ | |
if(e.getEntityLiving().getActivePotionEffect(ModPotionEffects.ROOT).getDuration() == 0){ | |
return; | |
} | |
else{ | |
e.getEntityLiving().setPositionAndUpdate(Math.round(e.getEntityLiving().posX-0.5)+0.5, Math.round(e.getEntityLiving().posY), Math.round(e.getEntityLiving().posZ-0.5)+0.5); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment