001package net.minecraft.entity.ai;
002
003import net.minecraft.entity.EntityLiving;
004import net.minecraft.entity.passive.EntityTameable;
005
006public class EntityAISit extends EntityAIBase
007{
008    private EntityTameable theEntity;
009
010    /** If the EntityTameable is sitting. */
011    private boolean isSitting = false;
012
013    public EntityAISit(EntityTameable par1EntityTameable)
014    {
015        this.theEntity = par1EntityTameable;
016        this.setMutexBits(5);
017    }
018
019    /**
020     * Returns whether the EntityAIBase should begin execution.
021     */
022    public boolean shouldExecute()
023    {
024        if (!this.theEntity.isTamed())
025        {
026            return false;
027        }
028        else if (this.theEntity.isInWater())
029        {
030            return false;
031        }
032        else if (!this.theEntity.onGround)
033        {
034            return false;
035        }
036        else
037        {
038            EntityLiving entityliving = this.theEntity.getOwner();
039            return entityliving == null ? true : (this.theEntity.getDistanceSqToEntity(entityliving) < 144.0D && entityliving.getAITarget() != null ? false : this.isSitting);
040        }
041    }
042
043    /**
044     * Execute a one shot task or start executing a continuous task
045     */
046    public void startExecuting()
047    {
048        this.theEntity.getNavigator().clearPathEntity();
049        this.theEntity.setSitting(true);
050    }
051
052    /**
053     * Resets the task
054     */
055    public void resetTask()
056    {
057        this.theEntity.setSitting(false);
058    }
059
060    /**
061     * Sets the sitting flag.
062     */
063    public void setSitting(boolean par1)
064    {
065        this.isSitting = par1;
066    }
067}