To debug this sort of issue you should just trace the execution. In your print statement you should also print out the value of the x1, y1, and z1. If those look correct, then you should use the debugger and set breakpoints in the path navigator and run the debugger.
In particular there are several reasons that it may return a null path. For example, the PathFinder#findPath() method is @Nullable. It will return null if the entity is already at the x, y, z location you specify -- in other words no path needed since it is already at the destination. The PathNavigator#getPathToPos() method is allso @Nullable (which makes sense because it calls the method above). It will return null if the navigator's canNavigate() method is false. That can happen if the entity is off the ground, if it cannot swim but is in liquid, or if the entity is riding another entity.
So there are many reasons the path might be null, you just need to check to see which one is happening in your case. So print out your x1, y1, z1 and then set breakpoints in the methods I just described and see how it executes.