Soul Snares should not trigger on players. Especially not in a weird way (#1216)

This commit is contained in:
Nicholas Ignoffo 2018-02-11 10:15:16 -08:00
parent 47482b6add
commit 163fe864e5

View file

@ -10,6 +10,7 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
public class EntitySoulSnare extends EntityThrowable { public class EntitySoulSnare extends EntityThrowable {
public EntitySoulSnare(World worldIn) { public EntitySoulSnare(World worldIn) {
super(worldIn); super(worldIn);
} }
@ -22,29 +23,21 @@ public class EntitySoulSnare extends EntityThrowable {
super(worldIn, x, y, z); super(worldIn, x, y, z);
} }
/**
* Called when this EntityThrowable hits a block or entity.
*/
@Override @Override
protected void onImpact(RayTraceResult result) { protected void onImpact(RayTraceResult result) {
if (result.entityHit == this.getThrower() && this.ticksExisted < 20) { if (result.entityHit == this.getThrower() || this.ticksExisted < 2 || getEntityWorld().isRemote)
return; return;
}
if (result.entityHit != null && result.entityHit != this.getThrower()) { if (result.entityHit instanceof EntityLivingBase) {
if (result.entityHit instanceof EntityLivingBase && result.entityHit.getEntityWorld().rand.nextDouble() < 0.25) { if (result.entityHit.getEntityWorld().rand.nextDouble() < 0.25)
((EntityLivingBase) result.entityHit).addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_SNARE, 300, 0)); ((EntityLivingBase) result.entityHit).addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_SNARE, 300, 0));
}
result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) 0); result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) 0);
} }
for (int j = 0; j < 8; ++j) { for (int j = 0; j < 8; ++j)
this.getEntityWorld().spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); this.getEntityWorld().spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
if (!this.getEntityWorld().isRemote) {
this.setDead(); this.setDead();
} }
} }
}