-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstantPlatformFallthrough.cs
45 lines (40 loc) · 1.27 KB
/
InstantPlatformFallthrough.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
44
45
using static Mono.Cecil.Cil.OpCodes;
using Terraria;
using MonoMod.Cil;
using System;
using Terraria.ModLoader;
namespace InstantPlatformFallthrough
{
public class InstantPlatformFallthrough : Mod
{
public override void Load()
{
Terraria.IL_Player.Update += il =>
{
try
{
var c = new ILCursor(il);
c.GotoNext(MoveType.After,
i => i.MatchStfld<Player>(nameof(Player.slideDir)),
i => i.Match(Ldc_I4_0),
i => i.Match(Stloc_S),
i => i.Match(Ldarg_0),
i => i.MatchLdfld<Player>(nameof(Player.controlDown)),
i => i.Match(Stloc_S)
);
var label = il.DefineLabel();
c.Emit(Ldloc_S, (byte)14); // fallThrough
c.Emit(Brfalse_S, label);
c.Emit(Ldc_I4_1);
c.Emit(Stloc_S, (byte)13); // ignorePlats
c.MarkLabel(label);
}
catch (Exception e)
{
Console.WriteLine(e);
}
};
base.Load();
}
}
}