Skip to content

Visor lifecycle

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

Contents

  1. Play Modes
  2. Lifecycle
  3. Addon Development

Play Modes

Visor supports 3 play modes. Each mode controls whether the VR session is initialized and when VR is rendered

VR_ENABLED (default)

  • Behavior
    • VR session is initialized on startup, and is playable from main menu
    • Require VR runtime & hardware

VR_WORLD_ONLY

  • Behavior
    • VR session is initialized same as VR_ENABLED, but is playable only in world
    • Require VR runtime & hardware

VR_DISABLED

  • Behavior
    • VR session never ininitialize
    • Does not require VR runtime & hardware
    • Modifies only rendering of remote VR players (if connected to server supporting Visor through mod or plugin)

Lifecycle

Three Boolean flags control runtime behavior:

Flag true means… false means…
VR_INITIALIZED VR session has been successfully created and is ready for rendering No VR session is available; VR cannot render
VR_ACTIVE VR is rendering Rendering falls back to vanilla
VR_FOCUSED VR is fully functional In-game menu overlay is shown and non-essential VR visuals are disabled to save performance.

Runtime

State is updated at the beginning of mc game loop

  1. Initialization

    • On startup, after mc resources are loaded, attempt to initialize VR.

    • If successful, set VR_INITIALIZED = true.

    • If in VR_DISABLED play mode, never initializes

  2. Activation

    • When VR_INITIALIZED == true and HMD has been put on, prepares game for VR and set VR_ACTIVE = true.

    • If HMD has been taken off while on server not supporting vanilla, the VR_ACTIVE stays true

    • If in VR_WORLD_ONLY play mode, activates only in world

  3. Focus

    • When VR_ACTIVE == true and VR session is focused, set `VR_FOCUSED = true'
  4. When VR has thrown an error

    • If the player is in-world, leaves it

    • VR session is destroyed, set VR_INITIALIZED = false

    • VR Play Mode changes to VR_DISABLED

    • Shows 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 check 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