Skip to content

Fix startup NullReferenceException on WorldBox 0.51.2 (resilient power-tab lookup)#72

Open
Skilvin wants to merge 1 commit into
WorldBoxOpenMods:masterfrom
Skilvin:fix/worldbox-0.51.2-powertab-nre
Open

Fix startup NullReferenceException on WorldBox 0.51.2 (resilient power-tab lookup)#72
Skilvin wants to merge 1 commit into
WorldBoxOpenMods:masterfrom
Skilvin:fix/worldbox-0.51.2-powertab-nre

Conversation

@Skilvin

@Skilvin Skilvin commented Jun 5, 2026

Copy link
Copy Markdown

Problem

On WorldBox 0.51.2 (build 719@5dec), starting the game with mods enabled crashes during NML's vanilla-tab reconstruction:

System.NullReferenceException: Object reference not set to an instance of an object
  at NeoModLoader.General.UI.Tab.WrappedPowersTab..ctor (PowersTab pPowersTab) [0x00015]
  at NeoModLoader.General.UI.Tab.TabMain.InitTab ()
  at NeoModLoader.General.UI.Tab.ReconstructedVanillaTab.Init ()
  at NeoModLoader.General.UI.Tab.TabManager._init ()

Root cause

PowerButtonCreator.GetTab(pId) locates the tab through a hard-coded UI hierarchy path:

CanvasBottom/BottomElements/BottomElementsMover/CanvasScrollView/Scroll View/Viewport/Content/Power Tabs/{pId}

In 0.51.2 this hierarchy changed, so transform.Find(...) returns null, GetTab returns null, and new WrappedPowersTab(null) throws an NRE on Tab.name.

Changes

  1. general/PowerButtonCreator.csGetTab: keep the fast hard-coded path, but fall back to locating the tab by its GameObject name via Resources.FindObjectsOfTypeAll<PowersTab>() when the path no longer matches. This makes the lookup resilient to UI-hierarchy changes.
  2. general/ui/tab/WrappedPowersTab.cs — constructor: add a null guard so the wrapper never NREs even if a tab is still not found (sets Modifiable = false and returns early).

Testing

Built in Debug and tested in-game on WorldBox 0.51.2 (experimental):

  • no more WrappedPowersTab..ctor NRE at boot,
  • power tabs reconstruct correctly,
  • vanilla + modded power buttons present.

GetTab() now falls back to finding the PowersTab by object name when the
hard-coded UI hierarchy path no longer matches (0.51.1+), and the
WrappedPowersTab constructor guards against a null tab to avoid an NRE
during vanilla-tab reconstruction.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant