diff --git a/Celeste.Mod.mm/MonoModRules.cs b/Celeste.Mod.mm/MonoModRules.cs
index c7ad21b5d..7f973edc3 100644
--- a/Celeste.Mod.mm/MonoModRules.cs
+++ b/Celeste.Mod.mm/MonoModRules.cs
@@ -394,6 +394,12 @@ class PatchCassetteBlockAwakeAttribute : Attribute { }
[MonoModCustomMethodAttribute(nameof(MonoModRules.PatchMountainRendererUpdate))]
class PatchMountainRendererUpdate : Attribute { }
+ ///
+ /// Patches the method to only set the player Speed.X if not in the RedDash state.
+ ///
+ [MonoModCustomMethodAttribute(nameof(MonoModRules.PatchPlayerBeforeUpTransition))]
+ class PatchPlayerBeforeUpTransition: Attribute { }
+
static class MonoModRules {
static bool IsCeleste;
@@ -2249,6 +2255,20 @@ public static void PatchMountainRendererUpdate(ILContext context, CustomAttribut
throw new Exception("MountainRenderer failed to patch key presses for keys: " + pressedKeys.Keys);
}
+ public static void PatchPlayerBeforeUpTransition(ILContext context, CustomAttribute attrib) {
+ FieldDefinition f_Player_StateMachine = context.Method.DeclaringType.FindField("StateMachine");
+ MethodDefinition m_StateMachine_get_State = f_Player_StateMachine.FieldType.Resolve().FindMethod("System.Int32 get_State()");
+
+ ILCursor cursor = new ILCursor(context);
+
+ cursor.Emit(OpCodes.Ldarg_0);
+ cursor.Emit(OpCodes.Ldfld, f_Player_StateMachine);
+ cursor.Emit(OpCodes.Callvirt, m_StateMachine_get_State);
+ cursor.Emit(OpCodes.Ldc_I4_5);
+ Instruction target = cursor.Clone().GotoNext(instr => instr.OpCode == OpCodes.Ldarg_0, instr => instr.MatchLdfld("Celeste.Player", "StateMachine")).Next;
+ cursor.Emit(OpCodes.Beq_S, target);
+ }
+
public static void PostProcessor(MonoModder modder) {
// Patch CrushBlock::AttackSequence's first alarm delegate manually because how would you even annotate it?
PatchCrushBlockFirstAlarm(modder.Module.GetType("Celeste.CrushBlock/<>c__DisplayClass41_0").FindMethod("b__1"));
diff --git a/Celeste.Mod.mm/Patches/Player.cs b/Celeste.Mod.mm/Patches/Player.cs
index ca1e43b93..2e7f21b14 100644
--- a/Celeste.Mod.mm/Patches/Player.cs
+++ b/Celeste.Mod.mm/Patches/Player.cs
@@ -197,6 +197,10 @@ public override void SceneEnd(Scene scene) {
level = null;
}
}
+
+ [MonoModIgnore]
+ [PatchPlayerBeforeUpTransition]
+ public new extern void BeforeUpTransition();
}
public static class PlayerExt {