Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. package theishiopian.ppd.entity.spells;
  2.  
  3. import net.minecraft.entity.EntityLivingBase;
  4. import net.minecraft.init.MobEffects;
  5. import net.minecraft.potion.PotionEffect;
  6. import net.minecraft.util.EnumParticleTypes;
  7. import net.minecraft.util.math.RayTraceResult;
  8. import net.minecraft.util.math.RayTraceResult.Type;
  9. import net.minecraft.world.World;
  10. import theishiopian.ppd.entity.EntitySpell;
  11.  
  12. public class EntityPoison extends EntitySpell
  13. {
  14.     public EntityPoison(World world)
  15.     {
  16.         super(world);
  17.     }
  18.  
  19.     public EntityPoison(World world, EntityLivingBase entity)
  20.     {
  21.         super(world, entity);
  22.         caster = entity;
  23.     }
  24.  
  25.     public EntityPoison(World world, double x, double y, double z)
  26.     {
  27.         super(world, x, y, z);
  28.     }
  29.  
  30.     @Override
  31.     protected void onImpact(RayTraceResult result)
  32.     {
  33.         if(result.typeOfHit == Type.BLOCK)
  34.         {
  35.             if(world.getBlockState(result.getBlockPos()).getCollisionBoundingBox(world, result.getBlockPos()) != null)setDead();
  36.         }
  37.         else if(result.entityHit != null && result.entityHit != caster && result.entityHit instanceof EntityLivingBase)
  38.         {
  39.  
  40.             ((EntityLivingBase) result.entityHit).addPotionEffect(new PotionEffect(MobEffects.POISON, 100));
  41.             ((EntityLivingBase) result.entityHit).setLastAttacker(caster);
  42.             ((EntityLivingBase) result.entityHit).setRevengeTarget(caster);
  43.             setDead();
  44.         }
  45.     }
  46.  
  47.     @Override
  48.     public void onUpdate()
  49.     {
  50.         super.onUpdate();
  51.         this.world.spawnParticle(EnumParticleTypes.SPELL_WITCH, true, this.posX, this.posY, this.posZ, this.motionX,
  52.                 this.motionY, this.motionZ, new int[0]);
  53.         this.world.spawnParticle(EnumParticleTypes.SPELL_WITCH, true, this.posX, this.posY, this.posZ, 0, 0, 0,
  54.                 new int[0]);
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement