| 1 | package net.minecraft.entity.passive;
|
| 2 |
|
| 3 | import net.minecraft.entity.EntityAgeable;
|
| 4 | import net.minecraft.entity.item.EntityItem;
|
| 5 | import net.minecraft.entity.player.EntityPlayer;
|
| 6 | import net.minecraft.init.Blocks;
|
| 7 | import net.minecraft.init.Items;
|
| 8 | import net.minecraft.item.ItemStack;
|
| 9 | import net.minecraft.util.EnumParticleTypes;
|
| 10 | import net.minecraft.world.World;
|
| 11 |
|
| 12 | public class EntityMooshroom extends EntityCow
|
| 13 | {
|
| 14 | public EntityMooshroom(World worldIn)
|
| 15 | {
|
| 16 | super(worldIn);
|
| 17 | this.setSize(0.9F, 1.3F);
|
| 18 | this.spawnableBlock = Blocks.mycelium;
|
| 19 | }
|
| 20 |
|
| 21 | /**
|
| 22 | * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
|
| 23 | */
|
| 24 | public boolean interact(EntityPlayer player)
|
| 25 | {
|
| 26 | ItemStack itemstack = player.inventory.getCurrentItem();
|
| 27 |
|
| 28 | if (itemstack != null && itemstack.getItem() == Items.bowl && this.getGrowingAge() >= 0)
|
| 29 | {
|
| 30 | if (itemstack.stackSize == 1)
|
| 31 | {
|
| 32 | player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.mushroom_stew));
|
| 33 | return true;
|
| 34 | }
|
| 35 |
|
| 36 | if (player.inventory.addItemStackToInventory(new ItemStack(Items.mushroom_stew)) && !player.capabilities.isCreativeMode)
|
| 37 | {
|
| 38 | player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
| 39 | return true;
|
| 40 | }
|
| 41 | }
|
| 42 |
|
| 43 | if (itemstack != null && itemstack.getItem() == Items.shears && this.getGrowingAge() >= 0)
|
| 44 | {
|
| 45 | this.setDead();
|
| 46 | this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY + (double)(this.height / 2.0F), this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
|
| 47 |
|
| 48 | if (!this.worldObj.isRemote)
|
| 49 | {
|
| 50 | EntityCow entitycow = new EntityCow(this.worldObj);
|
| 51 | entitycow.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
|
| 52 | entitycow.setHealth(this.getHealth());
|
| 53 | entitycow.renderYawOffset = this.renderYawOffset;
|
| 54 |
|
| 55 | if (this.hasCustomName())
|
| 56 | {
|
| 57 | entitycow.setCustomNameTag(this.getCustomNameTag());
|
| 58 | }
|
| 59 |
|
| 60 | this.worldObj.spawnEntityInWorld(entitycow);
|
| 61 |
|
| 62 | for (int i = 0; i < 5; ++i)
|
| 63 | {
|
| 64 | this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY + (double)this.height, this.posZ, new ItemStack(Blocks.red_mushroom)));
|
| 65 | }
|
| 66 |
|
| 67 | itemstack.damageItem(1, player);
|
| 68 | this.playSound("mob.sheep.shear", 1.0F, 1.0F);
|
| 69 | }
|
| 70 |
|
| 71 | return true;
|
| 72 | }
|
| 73 | else
|
| 74 | {
|
| 75 | return super.interact(player);
|
| 76 | }
|
| 77 | }
|
| 78 |
|
| 79 | public EntityMooshroom createChild(EntityAgeable ageable)
|
| 80 | {
|
| 81 | return new EntityMooshroom(this.worldObj);
|
| 82 | }
|
| 83 | }
|
| 84 |
|