001package net.minecraft.entity.ai;
002
003import net.minecraft.entity.EntityCreature;
004import net.minecraft.util.Vec3;
005
006public class EntityAIPanic extends EntityAIBase
007{
008    private EntityCreature theEntityCreature;
009    private float speed;
010    private double randPosX;
011    private double randPosY;
012    private double randPosZ;
013
014    public EntityAIPanic(EntityCreature par1EntityCreature, float par2)
015    {
016        this.theEntityCreature = par1EntityCreature;
017        this.speed = par2;
018        this.setMutexBits(1);
019    }
020
021    /**
022     * Returns whether the EntityAIBase should begin execution.
023     */
024    public boolean shouldExecute()
025    {
026        if (this.theEntityCreature.getAITarget() == null && !this.theEntityCreature.isBurning())
027        {
028            return false;
029        }
030        else
031        {
032            Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 5, 4);
033
034            if (vec3 == null)
035            {
036                return false;
037            }
038            else
039            {
040                this.randPosX = vec3.xCoord;
041                this.randPosY = vec3.yCoord;
042                this.randPosZ = vec3.zCoord;
043                return true;
044            }
045        }
046    }
047
048    /**
049     * Execute a one shot task or start executing a continuous task
050     */
051    public void startExecuting()
052    {
053        this.theEntityCreature.getNavigator().tryMoveToXYZ(this.randPosX, this.randPosY, this.randPosZ, this.speed);
054    }
055
056    /**
057     * Returns whether an in-progress EntityAIBase should continue executing
058     */
059    public boolean continueExecuting()
060    {
061        return !this.theEntityCreature.getNavigator().noPath();
062    }
063}