    001package net.minecraft.entity.projectile;
    002
    003import net.minecraft.entity.EntityLiving;
    004import net.minecraft.entity.passive.EntityChicken;
    005import net.minecraft.util.DamageSource;
    006import net.minecraft.util.MovingObjectPosition;
    007import net.minecraft.world.World;
    008
    009public class EntityEgg extends EntityThrowable
    010{
    011    public EntityEgg(World par1World)
    012    {
    013        super(par1World);
    014    }
    015
    016    public EntityEgg(World par1World, EntityLiving par2EntityLiving)
    017    {
    018        super(par1World, par2EntityLiving);
    019    }
    020
    021    public EntityEgg(World par1World, double par2, double par4, double par6)
    022    {
    023        super(par1World, par2, par4, par6);
    024    }
    025
    026    /**
    027     * Called when this EntityThrowable hits a block or entity.
    028     */
    029    protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    030    {
    031        if (par1MovingObjectPosition.entityHit != null)
    032        {
    033            par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0);
    034        }
    035
    036        if (!this.worldObj.isRemote && this.rand.nextInt(8) == 0)
    037        {
    038            byte b0 = 1;
    039
    040            if (this.rand.nextInt(32) == 0)
    041            {
    042                b0 = 4;
    043            }
    044
    045            for (int i = 0; i < b0; ++i)
    046            {
    047                EntityChicken entitychicken = new EntityChicken(this.worldObj);
    048                entitychicken.setGrowingAge(-24000);
    049                entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
    050                this.worldObj.spawnEntityInWorld(entitychicken);
    051            }
    052        }
    053
    054        for (int j = 0; j < 8; ++j)
    055        {
    056            this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
    057        }
    058
    059        if (!this.worldObj.isRemote)
    060        {
    061            this.setDead();
    062        }
    063    }
    064}