diff --git a/Torch/Managers/PatchManager/MSIL/MsilInstruction.cs b/Torch/Managers/PatchManager/MSIL/MsilInstruction.cs index 59d3723..af636b6 100644 --- a/Torch/Managers/PatchManager/MSIL/MsilInstruction.cs +++ b/Torch/Managers/PatchManager/MSIL/MsilInstruction.cs @@ -12,6 +12,7 @@ using Mono.Cecil.Cil; using MonoMod.Utils; using Torch.Managers.PatchManager.Transpile; using Torch.Utils; +using VRage.Game.VisualScripting; using OpCode = System.Reflection.Emit.OpCode; using OpCodes = System.Reflection.Emit.OpCodes; using OperandType = System.Reflection.Emit.OperandType; @@ -284,7 +285,11 @@ namespace Torch.Managers.PatchManager.MSIL type = type.BaseType; } - ((MsilOperandInline) Operand).Value = o; + if (Operand is not MsilOperandInline operandInline) + throw new InvalidOperationException( + $"Type {typeof(T).FullName} is not valid operand for {Operand?.GetType().Signature()}"); + + operandInline.Value = o; return this; }