package net.minecraft.entity.ai;

import net.minecraft.entity.EntityCreature;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.Vec3;

public class EntityAIMoveTowardsRestriction extends EntityAIBase
{
	private EntityCreature theEntity;
	private double movePosX;
	private double movePosY;
	private double movePosZ;
	private double movementSpeed;
	private static final String __OBFID = "CL_00001598";

	public EntityAIMoveTowardsRestriction(EntityCreature par1EntityCreature, double par2)
	{
		this.theEntity = par1EntityCreature;
		this.movementSpeed = par2;
		this.setMutexBits(1);
	}

	public boolean shouldExecute()
	{
		if (this.theEntity.isWithinHomeDistanceCurrentPosition())
		{
			return false;
		}
		else
		{
			ChunkCoordinates chunkcoordinates = this.theEntity.getHomePosition();
			Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 16, 7, this.theEntity.worldObj.getWorldVec3Pool().getVecFromPool((double)chunkcoordinates.posX, (double)chunkcoordinates.posY, (double)chunkcoordinates.posZ));

			if (vec3 == null)
			{
				return false;
			}
			else
			{
				this.movePosX = vec3.xCoord;
				this.movePosY = vec3.yCoord;
				this.movePosZ = vec3.zCoord;
				return true;
			}
		}
	}

	public boolean continueExecuting()
	{
		return !this.theEntity.getNavigator().noPath();
	}

	public void startExecuting()
	{
		this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.movementSpeed);
	}
}