Skip to content

Visor lifecycle

Bogdan T. edited this page May 24, 2025 · 31 revisions

Contents

  1. Play Modes
  2. Lifecycle
  3. Addon Development

Play Modes

Visor supports three play-modes. Each mode controls whether the VR session is initialized and when VR rendering occurs.

VR_ENABLED (default)

  • Behavior
    • VR session initializes on startup and is playable from the main menu.
    • Requires a VR runtime & hardware.

VR_WORLD_ONLY

  • Behavior
    • VR session initializes on startup but is playable only once you’re in-world.
    • Requires a VR runtime & hardware.

VR_DISABLED

  • Behavior
    • VR session never initializes.
    • Does not require VR runtime or hardware.
    • Only modifies rendering of remote VR players (if connected to a server/plugin supporting Visor).

Lifecycle

Flags

Flag true means false means
VR_INITIALIZED VR session has been created and is ready No VR session is available; VR cannot render
VR_ACTIVE VR is currently rendering Rendering falls back to vanilla
VR_FOCUSED VR is fully functional In-game menu overlay shows; non-essential VR visuals disabled

Runtime

State is updated at the start of each MC game loop:

  1. Initialization

    • After MC resources finish loading, attempt to initialize VR.
    • If successful, set VR_INITIALIZED = true.
    • If in VR_DISABLED mode, skip initialization entirely.
  2. Activation

    • When VR_INITIALIZED == true and the HMD is put on, prepare the game for VR and set VR_ACTIVE = true.
    • Edge case: If you remove the HMD on a non-vanilla server, VR_ACTIVE remains true.
    • In VR_WORLD_ONLY mode, activation only occurs once you’re in-world.
  3. Focus

    • When VR_ACTIVE == true and the VR session window has focus, set VR_FOCUSED = true.

Error Handling

When VR throws an error at any point:

  1. If the player is in-world, leave the world.
  2. Destroy the VR session and set VR_INITIALIZED = false.
  3. Switch play-mode to VR_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 extendable 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 extendable Visor elements, you won't need that mostly. Unless you want to have your logic active when VR_FOCUSED true

Clone this wiki locally