public ChunkPosition getNearestInstance(World par1World, int par2, int par3, int par4)
    {
        worldObj = par1World;
        rand.setSeed(par1World.getSeed());
        long l = rand.nextLong();
        long l1 = rand.nextLong();
        long l2 = (long)(par2 >> 4) * l;
        long l3 = (long)(par4 >> 4) * l1;
        rand.setSeed(l2 ^ l3 ^ par1World.getSeed());
        recursiveGenerate(par1World, par2 >> 4, par4 >> 4, 0, 0, null);
        double d = Double.MAX_VALUE;
        ChunkPosition chunkposition = null;
        Object obj = field_75053_d.values().iterator();

        do
        {
            if (!((Iterator)(obj)).hasNext())
            {
                break;
            }

            StructureStart structurestart = (StructureStart)((Iterator)(obj)).next();

            if (structurestart.isSizeableStructure())
            {
                StructureComponent structurecomponent = (StructureComponent)structurestart.getComponents().get(0);
                ChunkPosition chunkposition2 = structurecomponent.getCenter();
                int i = chunkposition2.x - par2;
                int k = chunkposition2.y - par3;
                int j1 = chunkposition2.z - par4;
                double d1 = i + i * k * k + j1 * j1;

                if (d1 < d)
                {
                    d = d1;
                    chunkposition = chunkposition2;
                }
            }
        }
        while (true);

        if (chunkposition != null)
        {
            return chunkposition;
        }

        obj = func_75052_o_();

        if (obj != null)
        {
            ChunkPosition chunkposition1 = null;
            Iterator iterator = ((List)(obj)).iterator();

            do
            {
                if (!iterator.hasNext())
                {
                    break;
                }

                ChunkPosition chunkposition3 = (ChunkPosition)iterator.next();
                int j = chunkposition3.x - par2;
                int i1 = chunkposition3.y - par3;
                int k1 = chunkposition3.z - par4;
                double d2 = j + j * i1 * i1 + k1 * k1;

                if (d2 < d)
                {
                    d = d2;
                    chunkposition1 = chunkposition3;
                }
            }
            while (true);

            return chunkposition1;
        }
        else
        {
            return null;
        }
    }