@Override
protected void onImpact(RayTraceResult position) {
if (position.entityHit != null) {
position.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
}
for (int i = 0; i < 32; ++i) {
this.world.spawnParticle(EnumParticleTypes.PORTAL, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian());
}
if (!this.world.isRemote) {
if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP) {
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower();
if (entityplayermp.connection.netManager.isChannelOpen() && entityplayermp.world == this.world) {
EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 0.0F);
if (!MinecraftForge.EVENT_BUS.post(event)) {
if (this.getThrower().isRiding()) {
this.getThrower().dismountRidingEntity();
}
this.getThrower().setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ());
this.getThrower().fallDistance = 0.0F;
this.getThrower().attackEntityFrom(DamageSource.FALL, event.getAttackDamage());
this.getThrower().addPotionEffect(new PotionEffect(MobEffects.SLOWNESS,
BloodPearlOfTeleportationConfig.slownessDuration * 20, 2));
}
}
}
this.setDead();
}
}