1717
1818package com .lambda .mixin ;
1919
20+ import com .lambda .core .TimerManager ;
2021import com .lambda .event .EventFlow ;
2122import com .lambda .event .events .ClientEvent ;
2223import com .lambda .event .events .InventoryEvent ;
4243import org .jetbrains .annotations .Nullable ;
4344import org .spongepowered .asm .mixin .Mixin ;
4445import org .spongepowered .asm .mixin .Shadow ;
46+ import org .spongepowered .asm .mixin .Unique ;
4547import org .spongepowered .asm .mixin .injection .At ;
4648import org .spongepowered .asm .mixin .injection .Inject ;
4749import org .spongepowered .asm .mixin .injection .Redirect ;
@@ -60,6 +62,9 @@ public class MinecraftClientMixin {
6062 @ Shadow
6163 public int itemUseCooldown ;
6264
65+ @ Unique
66+ private boolean lambda$inputHandledThisTick ;
67+
6368 @ Inject (method = "close" , at = @ At ("HEAD" ))
6469 void closeImGui (CallbackInfo ci ) {
6570 DearImGui .INSTANCE .destroy ();
@@ -74,6 +79,8 @@ void onLoopTick(boolean tick, Operation<Void> original) {
7479
7580 @ WrapMethod (method = "tick" )
7681 void onTick (Operation <Void > original ) {
82+ this .lambda$inputHandledThisTick = false ;
83+
7784 EventFlow .post (TickEvent .Pre .INSTANCE );
7885 original .call ();
7986 EventFlow .post (TickEvent .Post .INSTANCE );
@@ -91,10 +98,18 @@ void onInput(MinecraftClient instance, Operation<Void> original) {
9198 EventFlow .post (TickEvent .Input .Pre .INSTANCE );
9299 original .call (instance );
93100 EventFlow .post (TickEvent .Input .Post .INSTANCE );
101+
102+ this .lambda$inputHandledThisTick = true ;
94103 }
95104
96105 @ WrapOperation (method = "tick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/render/WorldRenderer;tick()V" ))
97106 void onWorldRenderer (WorldRenderer instance , Operation <Void > original ) {
107+ if (!this .lambda$inputHandledThisTick ) {
108+ EventFlow .post (TickEvent .Input .Pre .INSTANCE );
109+ EventFlow .post (TickEvent .Input .Post .INSTANCE );
110+ this .lambda$inputHandledThisTick = true ;
111+ }
112+
98113 EventFlow .post (TickEvent .WorldRender .Pre .INSTANCE );
99114 original .call (instance );
100115 EventFlow .post (TickEvent .WorldRender .Post .INSTANCE );
@@ -171,4 +186,14 @@ void injectFastPlace(CallbackInfo ci) {
171186
172187 itemUseCooldown = Interact .getPlaceDelay ();
173188 }
189+
190+ @ WrapMethod (method = "getTargetMillisPerTick" )
191+ float getTargetMillisPerTick (float millis , Operation <Float > original ) {
192+ var length = TimerManager .INSTANCE .getLength ();
193+
194+ if (length == TimerManager .DEFAULT_LENGTH )
195+ return original .call (millis );
196+ else
197+ return (float ) TimerManager .INSTANCE .getLength ();
198+ }
174199}
0 commit comments