2016-01-08 14:56:36 -05:00
|
|
|
package WayofTime.bloodmagic.entity.projectile;
|
|
|
|
|
2017-08-15 20:21:54 -07:00
|
|
|
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
|
2016-01-08 14:56:36 -05:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.projectile.EntityThrowable;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
|
|
|
import net.minecraft.util.DamageSource;
|
|
|
|
import net.minecraft.util.EnumParticleTypes;
|
2016-03-18 16:57:57 -04:00
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
2016-01-08 14:56:36 -05:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public class EntitySoulSnare extends EntityThrowable {
|
2018-02-11 10:15:16 -08:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public EntitySoulSnare(World worldIn) {
|
2016-01-08 14:56:36 -05:00
|
|
|
super(worldIn);
|
|
|
|
}
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public EntitySoulSnare(World worldIn, EntityLivingBase throwerIn) {
|
2016-01-08 14:56:36 -05:00
|
|
|
super(worldIn, throwerIn);
|
|
|
|
}
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public EntitySoulSnare(World worldIn, double x, double y, double z) {
|
2016-01-08 14:56:36 -05:00
|
|
|
super(worldIn, x, y, z);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
protected void onImpact(RayTraceResult result) {
|
2018-02-11 10:15:16 -08:00
|
|
|
if (result.entityHit == this.getThrower() || this.ticksExisted < 2 || getEntityWorld().isRemote)
|
2016-11-11 10:42:56 -05:00
|
|
|
return;
|
|
|
|
|
2018-02-11 10:15:16 -08:00
|
|
|
if (result.entityHit instanceof EntityLivingBase) {
|
|
|
|
if (result.entityHit.getEntityWorld().rand.nextDouble() < 0.25)
|
2017-08-15 20:21:54 -07:00
|
|
|
((EntityLivingBase) result.entityHit).addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_SNARE, 300, 0));
|
2016-01-08 14:56:36 -05:00
|
|
|
|
2016-03-18 16:57:57 -04:00
|
|
|
result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) 0);
|
2016-01-08 14:56:36 -05:00
|
|
|
}
|
|
|
|
|
2018-02-11 10:15:16 -08:00
|
|
|
for (int j = 0; j < 8; ++j)
|
2016-12-12 19:56:36 -08:00
|
|
|
this.getEntityWorld().spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
|
2016-01-08 14:56:36 -05:00
|
|
|
|
2018-02-11 10:15:16 -08:00
|
|
|
this.setDead();
|
2016-01-08 14:56:36 -05:00
|
|
|
}
|
|
|
|
}
|