From 6ab286bb0b21b8af9afd1983e283c87ecf92445f Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Thu, 5 Mar 2026 18:28:34 +0800 Subject: [PATCH] Fix crash in NeutronStarHandler.OnEnable() --- UXAssist/Patches/PersistPatch.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/UXAssist/Patches/PersistPatch.cs b/UXAssist/Patches/PersistPatch.cs index 983b118..e43ab41 100644 --- a/UXAssist/Patches/PersistPatch.cs +++ b/UXAssist/Patches/PersistPatch.cs @@ -172,6 +172,25 @@ public class PersistPatch : PatchImpl return false; } + // Fix crash in NeutronStarHandler.OnEnable() + [HarmonyTranspiler] + [HarmonyPatch(typeof(NeutronStarHandler), nameof(NeutronStarHandler.OnEnable))] + private static IEnumerable NeutronStarHandler_OnEnable_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.MatchForward(false, + new CodeMatch(OpCodes.Ldarg_0), + new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(NeutronStarHandler), nameof(NeutronStarHandler.streamRenderer))), + new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Renderer), nameof(Renderer.sharedMaterial))) + ).RemoveInstructions(3).InsertAndAdvance( + Transpilers.EmitDelegate(() => { + return Configs.builtin.neutronStarPrefab.streamRenderer.sharedMaterial; + }) + ); + + return matcher.InstructionEnumeration(); + } + #region Cluster Upload Result [HarmonyPostfix]