BloodMagic/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySoulSnare.java

60 lines
1.8 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.entity.projectile;
2017-08-15 20:21:54 -07:00
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
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;
import net.minecraft.world.World;
public class EntitySoulSnare extends EntityThrowable
{
public EntitySoulSnare(World worldIn)
{
super(worldIn);
}
public EntitySoulSnare(World worldIn, EntityLivingBase throwerIn)
{
super(worldIn, throwerIn);
}
public EntitySoulSnare(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
/**
* Called when this EntityThrowable hits a block or entity.
*/
@Override
2016-03-18 16:57:57 -04:00
protected void onImpact(RayTraceResult result)
{
if (result.entityHit == this.getThrower() && this.ticksExisted < 20)
{
return;
}
if (result.entityHit != null && result.entityHit != this.getThrower())
{
2016-12-12 19:56:36 -08:00
if (result.entityHit instanceof EntityLivingBase && 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-03-18 16:57:57 -04:00
result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) 0);
}
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-12-12 19:56:36 -08:00
if (!this.getEntityWorld().isRemote)
{
this.setDead();
}
}
}