Skip to content

Visor lifecycle

Bogdan T. edited this page Jun 14, 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 play-mode is not DISABLED, attempts to initialize VR session.
    • If successful, state-mode changes to INITIALIZED.
  2. Activation

    • When state-mode is INITIALIZED and the HMD is put on, prepares the game for VR and changes state-mode to ACTIVE.
    • Edge case: If you take off the HMD on a server not supporting vanilla, state-mode will remain ACTIVE.
    • In WORLD_ONLY play-mode, activation only occurs once you’re in-world.
  3. Focus

    • When state-mode is ACTIVE and the VR session window has focus, state-mode 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 initially is created for vanilla 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 true

Clone this wiki locally