Ok, finally found it. I assume the order is acceptable. -
for (X = start.x; X <= end.x; X++) {
for (Z = start.z; Z <= end.z; Z++) {
for (Y = surface; Y > 1; Y--) {
BlockPos pos = new BlockPos(X, Y, Z);
if (world.isAirBlock(pos)) continue;
stateAt = world.getBlockState(pos);
blockAt = stateAt.getBlock();
if (isMiningOre(blockAt, (mode.id().equals("vanilla")))) {
BlockPos top = new BlockPos(X, surface, Z);
blockAt.harvestBlock(world, entityplayer, top, stateAt, null, ItemStack.EMPTY);
blockAt.dropXpOnBlockBreak(world, top,blockAt.getExpDrop(stateAt, world, pos, fortune));
world.setBlockState(pos, Blocks.STONE.getDefaultState());
blockAt.onBlockDestroyedByPlayer(world, pos, stateAt);
cnt++;
}
}
}
}