| 1 | package net.minecraft.entity.projectile;
|
| 2 |
|
| 3 | import net.minecraft.entity.EntityLivingBase;
|
| 4 | import net.minecraft.entity.passive.EntityChicken;
|
| 5 | import net.minecraft.init.Items;
|
| 6 | import net.minecraft.item.Item;
|
| 7 | import net.minecraft.util.DamageSource;
|
| 8 | import net.minecraft.util.EnumParticleTypes;
|
| 9 | import net.minecraft.util.MovingObjectPosition;
|
| 10 | import net.minecraft.world.World;
|
| 11 |
|
| 12 | public class EntityEgg extends EntityThrowable
|
| 13 | {
|
| 14 | public EntityEgg(World worldIn)
|
| 15 | {
|
| 16 | super(worldIn);
|
| 17 | }
|
| 18 |
|
| 19 | public EntityEgg(World worldIn, EntityLivingBase throwerIn)
|
| 20 | {
|
| 21 | super(worldIn, throwerIn);
|
| 22 | }
|
| 23 |
|
| 24 | public EntityEgg(World worldIn, double x, double y, double z)
|
| 25 | {
|
| 26 | super(worldIn, x, y, z);
|
| 27 | }
|
| 28 |
|
| 29 | /**
|
| 30 | * Called when this EntityThrowable hits a block or entity.
|
| 31 | */
|
| 32 | protected void onImpact(MovingObjectPosition p_70184_1_)
|
| 33 | {
|
| 34 | if (p_70184_1_.entityHit != null)
|
| 35 | {
|
| 36 | p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
|
| 37 | }
|
| 38 |
|
| 39 | if (!this.worldObj.isRemote && this.rand.nextInt(8) == 0)
|
| 40 | {
|
| 41 | int i = 1;
|
| 42 |
|
| 43 | if (this.rand.nextInt(32) == 0)
|
| 44 | {
|
| 45 | i = 4;
|
| 46 | }
|
| 47 |
|
| 48 | for (int j = 0; j < i; ++j)
|
| 49 | {
|
| 50 | EntityChicken entitychicken = new EntityChicken(this.worldObj);
|
| 51 | entitychicken.setGrowingAge(-24000);
|
| 52 | entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
|
| 53 | this.worldObj.spawnEntityInWorld(entitychicken);
|
| 54 | }
|
| 55 | }
|
| 56 |
|
| 57 | double d0 = 0.08D;
|
| 58 |
|
| 59 | for (int k = 0; k < 8; ++k)
|
| 60 | {
|
| 61 | this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, this.posX, this.posY, this.posZ, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, new int[] {Item.getIdFromItem(Items.egg)});
|
| 62 | }
|
| 63 |
|
| 64 | if (!this.worldObj.isRemote)
|
| 65 | {
|
| 66 | this.setDead();
|
| 67 | }
|
| 68 | }
|
| 69 | }
|
| 70 |
|