float angles = new float[3];
cam.getRotation().toAngles(angles); // we get the cam angles here
angles[0] = 0; // you don’t want to rotate along the x-axis, so we set it to 0
angles[2] = 0; // you don’t want to rotate along the z-axis, so we set it to 0
player.setLocalRotation(player.getLocalRotation().fromAngles(angles)); // apply new player rot