Yeah, I agree, my algorithm is very weird and not efficient. I created mineArea's with areas that cointains ores. Now, if i = 0, it goes to Area[0], mine all ores there, then goes to Area[1] and etc. Also, I changed this part of the code, after posting here.
Entity oreVein = objects.closest(DIRT_NAME);
is now insade that while lopp.
People in the other thread pointed out to me, that ores I was trying to mine were dynamic. It changes state even if it still exists. That's why this happened.
BTW, really appreciate your help, and discussions