Skip to content

Instantly share code, notes, and snippets.

@Brogolem35
Created August 11, 2017 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Brogolem35/76738b6f1fec3c327d7178d5db9efb59 to your computer and use it in GitHub Desktop.
Save Brogolem35/76738b6f1fec3c327d7178d5db9efb59 to your computer and use it in GitHub Desktop.
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