Let me see if I understand what you are doing correctly.
Instead of checking if your ray is intersecting each world cube you have divided your world into multiple planes based on Z axis position and now you are simply checking ray collision with each individual Z plane.
But you encountered problems when ray can pas through two nearby Z planes without triggering collision and you want to know what distance (steps) you should have between these Z panes in order to prevent that. This could happens because angle of your ray relative to the Z axis is smaller than the angle between two opposite corners of the same cube face which in case of step 1 (distance between two nearby Z planes is same as the size of the cube) would be any angle that is smaller than 45 degrees. In case of step 0.5 it could happen for any angle lower than 22.5. In case of step 0.25 it could happen for any angle lower than 11.25 and so on.

But this is not how ray-tracing is being done. When doing ray-tracing you are always checking the collision between your ray and every possible collidable object in your world.
Now since you are working with cube based world you can avoid the need for checking ray collision with every cube in the world by grouping multiple cubes into one larger cube so you first check to see if your ray has collided to this larger cube and only then further check to see if it also collided with any smaller cubes. This approach would be called heuristic collision detection and the data structure that you would use for storing information about your cubes would probably be Octree.