def saveLastPosition(self, mainViewport, dimension):
        '''
        Saves the final position of the camera viewport when the world is closed or MCEdit is exited
        
        :param mainViewport: The reference to viewport object
        :param dimension: The dimension the camera viewport is currently in
        :type dimension: int
        '''
        log.info('Saving last position.')
        if "LastPosition" in self.nbt_waypoints:
            del self.nbt_waypoints["LastPosition"]
        topTag = nbt.TAG_Compound()
        topTag["Dimension"] = nbt.TAG_Int(dimension)

        pos = nbt.TAG_List()
        pos.append(nbt.TAG_Float(mainViewport.cameraPosition[0]))
        pos.append(nbt.TAG_Float(mainViewport.cameraPosition[1]))
        pos.append(nbt.TAG_Float(mainViewport.cameraPosition[2]))
        topTag["Coordinates"] = pos

        rot = nbt.TAG_List()
        rot.append(nbt.TAG_Float(mainViewport.yaw))
        rot.append(nbt.TAG_Float(mainViewport.pitch))
        topTag["Rotation"] = rot

        self.nbt_waypoints["LastPosition"] = topTag
        self.save()
        self.already_saved = True

        Saves the final position of the camera viewport when the world is closed or MCEdit is exited
        
        :param mainViewport: The reference to viewport object
        :param dimension: The dimension the camera viewport is currently in
        :type dimension: int
        
waypoints.py