You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			155 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Java
		
	
			
		
		
	
	
			155 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Java
		
	
package net.minecraft.entity.passive;
 | 
						|
 | 
						|
import net.minecraft.block.Block;
 | 
						|
import net.minecraft.entity.EntityAgeable;
 | 
						|
import net.minecraft.entity.SharedMonsterAttributes;
 | 
						|
import net.minecraft.entity.ai.EntityAIFollowParent;
 | 
						|
import net.minecraft.entity.ai.EntityAILookIdle;
 | 
						|
import net.minecraft.entity.ai.EntityAIMate;
 | 
						|
import net.minecraft.entity.ai.EntityAIPanic;
 | 
						|
import net.minecraft.entity.ai.EntityAISwimming;
 | 
						|
import net.minecraft.entity.ai.EntityAITempt;
 | 
						|
import net.minecraft.entity.ai.EntityAIWander;
 | 
						|
import net.minecraft.entity.ai.EntityAIWatchClosest;
 | 
						|
import net.minecraft.entity.player.EntityPlayer;
 | 
						|
import net.minecraft.init.Items;
 | 
						|
import net.minecraft.item.Item;
 | 
						|
import net.minecraft.item.ItemStack;
 | 
						|
import net.minecraft.world.World;
 | 
						|
 | 
						|
public class EntityCow extends EntityAnimal
 | 
						|
{
 | 
						|
    private static final String __OBFID = "CL_00001640";
 | 
						|
 | 
						|
    public EntityCow(World p_i1683_1_)
 | 
						|
    {
 | 
						|
        super(p_i1683_1_);
 | 
						|
        this.setSize(0.9F, 1.3F);
 | 
						|
        this.getNavigator().setAvoidsWater(true);
 | 
						|
        this.tasks.addTask(0, new EntityAISwimming(this));
 | 
						|
        this.tasks.addTask(1, new EntityAIPanic(this, 2.0D));
 | 
						|
        this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
 | 
						|
        this.tasks.addTask(3, new EntityAITempt(this, 1.25D, Items.wheat, false));
 | 
						|
        this.tasks.addTask(4, new EntityAIFollowParent(this, 1.25D));
 | 
						|
        this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
 | 
						|
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
 | 
						|
        this.tasks.addTask(7, new EntityAILookIdle(this));
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns true if the newer Entity AI code should be run
 | 
						|
     */
 | 
						|
    public boolean isAIEnabled()
 | 
						|
    {
 | 
						|
        return true;
 | 
						|
    }
 | 
						|
 | 
						|
    protected void applyEntityAttributes()
 | 
						|
    {
 | 
						|
        super.applyEntityAttributes();
 | 
						|
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
 | 
						|
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000000298023224D);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns the sound this mob makes while it's alive.
 | 
						|
     */
 | 
						|
    protected String getLivingSound()
 | 
						|
    {
 | 
						|
        return "mob.cow.say";
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns the sound this mob makes when it is hurt.
 | 
						|
     */
 | 
						|
    protected String getHurtSound()
 | 
						|
    {
 | 
						|
        return "mob.cow.hurt";
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns the sound this mob makes on death.
 | 
						|
     */
 | 
						|
    protected String getDeathSound()
 | 
						|
    {
 | 
						|
        return "mob.cow.hurt";
 | 
						|
    }
 | 
						|
 | 
						|
    protected void func_145780_a(int x, int y, int z, Block blockIn)
 | 
						|
    {
 | 
						|
        this.playSound("mob.cow.step", 0.15F, 1.0F);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns the volume for the sounds this mob makes.
 | 
						|
     */
 | 
						|
    protected float getSoundVolume()
 | 
						|
    {
 | 
						|
        return 0.4F;
 | 
						|
    }
 | 
						|
 | 
						|
    protected Item getDropItem()
 | 
						|
    {
 | 
						|
        return Items.leather;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param
 | 
						|
     * par2 - Level of Looting used to kill this mob.
 | 
						|
     */
 | 
						|
    protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
 | 
						|
    {
 | 
						|
        int j = this.rand.nextInt(3) + this.rand.nextInt(1 + p_70628_2_);
 | 
						|
        int k;
 | 
						|
 | 
						|
        for (k = 0; k < j; ++k)
 | 
						|
        {
 | 
						|
            this.dropItem(Items.leather, 1);
 | 
						|
        }
 | 
						|
 | 
						|
        j = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + p_70628_2_);
 | 
						|
 | 
						|
        for (k = 0; k < j; ++k)
 | 
						|
        {
 | 
						|
            if (this.isBurning())
 | 
						|
            {
 | 
						|
                this.dropItem(Items.cooked_beef, 1);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                this.dropItem(Items.beef, 1);
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 | 
						|
     */
 | 
						|
    public boolean interact(EntityPlayer p_70085_1_)
 | 
						|
    {
 | 
						|
        ItemStack itemstack = p_70085_1_.inventory.getCurrentItem();
 | 
						|
 | 
						|
        if (itemstack != null && itemstack.getItem() == Items.bucket && !p_70085_1_.capabilities.isCreativeMode)
 | 
						|
        {
 | 
						|
            if (itemstack.stackSize-- == 1)
 | 
						|
            {
 | 
						|
                p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, new ItemStack(Items.milk_bucket));
 | 
						|
            }
 | 
						|
            else if (!p_70085_1_.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket)))
 | 
						|
            {
 | 
						|
                p_70085_1_.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false);
 | 
						|
            }
 | 
						|
 | 
						|
            return true;
 | 
						|
        }
 | 
						|
        else
 | 
						|
        {
 | 
						|
            return super.interact(p_70085_1_);
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    public EntityCow createChild(EntityAgeable p_90011_1_)
 | 
						|
    {
 | 
						|
        return new EntityCow(this.worldObj);
 | 
						|
    }
 | 
						|
} |