Skip to content

Visor lifecycle

Bogdan edited this page Jul 30, 2025 · 31 revisions

Contents

  1. API
  2. Lifecycle
  3. Addon Development

API

API classes related to lifecycle:

To access, you need to use VisorAPI#clientState() method

Lifecycle

Runtime

State is updated at the beginning of Minecraft game loop:

  1. Initialization

    • After MC resources finish loading, initializes VisorClient, client-related classes and addons
    • If VRPlayMode is not DISABLED, attempts to initialize VR session.
    • If successful, VRStateMode changes to INITIALIZED.
  2. Activation

    • When VRStateMode is INITIALIZED and the current VRPlayMode allows active VR, prepares the game for VR and changes state-mode to ACTIVE.
    • Edge case: If you are on a server not supporting vanilla, VRStateMode will remain ACTIVE.
  3. Focus

    • When VRStateMode is ACTIVE and the VR session window has focus, VRStateMode changed to FOCUSED, otherwise goes back to ACTIVE

Error Handling

When VR throws an error at any point:

  1. If the player is in-world, disconnect.
  2. Destroy the VR session and set state-mode to OFF.
  3. Switch play-mode to DISABLED.
  4. Show the VR error screen.

Addon Development

You should avoid any modifications of Visor Lifecycle to not risk the instability and issues with other addons

How to use

Make sure your addon checks whether VR is currently active/focused to run your logic if you are doing something outside of Visor elements scope.

It is especially important when you use mixin to modify minecraft for VR or your mod is initially created for non-VR minecraft and you want to add support for VR.

For Visor elements, you won't need that mostly. Unless you want to have your logic active when VR_FOCUSED is true

Clone this wiki locally