-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrettyPatchMod.cs
43 lines (37 loc) · 1.33 KB
/
PrettyPatchMod.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using JetBrains.Annotations;
using Microsoft.Xna.Framework;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using PrettyPatch.API;
using PrettyPatch.API.V1.Detouring;
using PrettyPatch.API.V1.ILEditing;
using PrettyPatch.Exceptions;
using PrettyPatch.Util;
using Terraria.ModLoader;
namespace PrettyPatch
{
[UsedImplicitly]
public sealed class PrettyPatchMod : Mod
{
// Should be used sparingly. Ideally, never.
internal static PrettyPatchMod BackupInstanceUnsafe = null!;
public PrettyPatchMod() {
BackupInstanceUnsafe = this;
if (!Bootstrapper.Bootstrap(this, ApiVersion.One))
throw new BootstrapFailedModLoadException(Messages.BootstrapFailedPrettyPatch(ApiVersion.One.GetVersion().ToString()));
}
[ILEdit("Terraria.Main", "System.Void DrawCursor(Microsoft.Xna.Framework.Vector2,System.Boolean)")]
public static void DrawCursorEdit(ILContext il) {
ILCursor c = new(il);
c.Emit(OpCodes.Ldarg_1);
c.Emit(OpCodes.Ldc_I4_0);
c.Emit(OpCodes.Ceq);
c.Emit(OpCodes.Starg, 1);
}
// TODO: Null checking here? :thinking:
internal static PrettyPatchMod Get() {
return ModContent.GetInstance<PrettyPatchMod>() ?? BackupInstanceUnsafe;
}
}
}