    001package net.minecraft.entity.item;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.entity.EntityLiving;
    006import net.minecraft.entity.player.EntityPlayerMP;
    007import net.minecraft.entity.projectile.EntityThrowable;
    008import net.minecraft.util.DamageSource;
    009import net.minecraft.util.MovingObjectPosition;
    010import net.minecraft.world.World;
    011
    012public class EntityEnderPearl extends EntityThrowable
    013{
    014    public EntityEnderPearl(World par1World)
    015    {
    016        super(par1World);
    017    }
    018
    019    public EntityEnderPearl(World par1World, EntityLiving par2EntityLiving)
    020    {
    021        super(par1World, par2EntityLiving);
    022    }
    023
    024    @SideOnly(Side.CLIENT)
    025    public EntityEnderPearl(World par1World, double par2, double par4, double par6)
    026    {
    027        super(par1World, par2, par4, par6);
    028    }
    029
    030    /**
    031     * Called when this EntityThrowable hits a block or entity.
    032     */
    033    protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    034    {
    035        if (par1MovingObjectPosition.entityHit != null)
    036        {
    037            par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0);
    038        }
    039
    040        for (int i = 0; i < 32; ++i)
    041        {
    042            this.worldObj.spawnParticle("portal", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian());
    043        }
    044
    045        if (!this.worldObj.isRemote)
    046        {
    047            if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP)
    048            {
    049                EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower();
    050
    051                if (!entityplayermp.playerNetServerHandler.connectionClosed && entityplayermp.worldObj == this.worldObj)
    052                {
    053                    this.getThrower().setPositionAndUpdate(this.posX, this.posY, this.posZ);
    054                    this.getThrower().fallDistance = 0.0F;
    055                    this.getThrower().attackEntityFrom(DamageSource.fall, 5);
    056                }
    057            }
    058
    059            this.setDead();
    060        }
    061    }
    062}