Skip to content

Commit 0297397

Browse files
committed
Add a setting to InventoryTweaks to make input handling happen every frame instead of every tick.
Closes #6065
1 parent c9cc69a commit 0297397

4 files changed

Lines changed: 58 additions & 7 deletions

File tree

src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ public interface MinecraftClientAccessor {
7272
@Mutable
7373
@Accessor("apiServices")
7474
void meteor$setApiServices(ApiServices apiServices);
75+
76+
@Invoker("handleInputEvents")
77+
void meteor$handleInputEvents();
7578
}

src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientMixin.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import meteordevelopment.meteorclient.mixininterface.IMinecraftClient;
2525
import meteordevelopment.meteorclient.systems.config.Config;
2626
import meteordevelopment.meteorclient.systems.modules.Modules;
27+
import meteordevelopment.meteorclient.systems.modules.misc.InventoryTweaks;
2728
import meteordevelopment.meteorclient.systems.modules.movement.GUIMove;
2829
import meteordevelopment.meteorclient.systems.modules.player.FastUse;
2930
import meteordevelopment.meteorclient.systems.modules.player.Multitask;
@@ -90,6 +91,9 @@ public abstract class MinecraftClientMixin implements IMinecraftClient {
9091
@Mutable
9192
private Framebuffer framebuffer;
9293

94+
@Shadow
95+
protected abstract void handleBlockBreaking(boolean breaking);
96+
9397
@Inject(method = "<init>", at = @At("TAIL"))
9498
private void onInit(CallbackInfo info) {
9599
MeteorClient.INSTANCE.onInitializeClient();
@@ -279,6 +283,31 @@ private boolean hasOutlineModifyIsOutline(boolean original, Entity entity) {
279283
return esp.getColor(entity) != null || original;
280284
}
281285

286+
287+
// faster inputs
288+
289+
@Unique
290+
private boolean isBreaking = false;
291+
292+
@WrapWithCondition(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V"))
293+
private boolean wrapHandleInputEvents(MinecraftClient instance) {
294+
return !Modules.get().get(InventoryTweaks.class).frameInput();
295+
}
296+
297+
@WrapWithCondition(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleBlockBreaking(Z)V"))
298+
private boolean wrapHandleBlockBreaking(MinecraftClient instance, boolean breaking) {
299+
isBreaking = breaking;
300+
return !Modules.get().get(InventoryTweaks.class).frameInput();
301+
}
302+
303+
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.AFTER))
304+
private void afterHandleInputEvents(CallbackInfo ci) {
305+
if (!Modules.get().get(InventoryTweaks.class).frameInput()) return;
306+
307+
handleBlockBreaking(isBreaking);
308+
isBreaking = false;
309+
}
310+
282311
// Interface
283312

284313
@Override

src/main/java/meteordevelopment/meteorclient/mixin/RenderSystemMixin.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import com.mojang.blaze3d.systems.RenderSystem;
99
import meteordevelopment.meteorclient.renderer.MeshUniforms;
10+
import meteordevelopment.meteorclient.systems.modules.Modules;
11+
import meteordevelopment.meteorclient.systems.modules.misc.InventoryTweaks;
1012
import meteordevelopment.meteorclient.utils.render.postprocess.ChamsShader;
1113
import meteordevelopment.meteorclient.utils.render.postprocess.OutlineUniforms;
1214
import meteordevelopment.meteorclient.utils.render.postprocess.PostProcessShader;
@@ -15,6 +17,8 @@
1517
import org.spongepowered.asm.mixin.injection.Inject;
1618
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1719

20+
import static meteordevelopment.meteorclient.MeteorClient.mc;
21+
1822
@Mixin(RenderSystem.class)
1923
public abstract class RenderSystemMixin {
2024
@Inject(method = "flipFrame", at = @At("TAIL"))
@@ -23,5 +27,8 @@ public abstract class RenderSystemMixin {
2327
PostProcessShader.flipFrame();
2428
ChamsShader.flipFrame();
2529
OutlineUniforms.flipFrame();
30+
31+
if (Modules.get() == null || mc.player == null) return;
32+
if (Modules.get().get(InventoryTweaks.class).frameInput()) ((MinecraftClientAccessor) mc).meteor$handleInputEvents();
2633
}
2734
}

src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ public class InventoryTweaks extends Module {
7070
.build()
7171
);
7272

73+
private final Setting<Boolean> uncapBundleScrolling = sgGeneral.add(new BoolSetting.Builder()
74+
.name("uncap-bundle-scrolling")
75+
.description("Whether to uncap the bundle scrolling feature to let you select any item.")
76+
.defaultValue(true)
77+
.build()
78+
);
79+
80+
private final Setting<Boolean> frameInput = sgGeneral.add(new BoolSetting.Builder()
81+
.name("frame-input-handling")
82+
.description("Changes input handling to work every frame instead of every tick. A very minor effect but may\n" +
83+
"make inputs feel smoother, especially in laggy environments. Will flag anticheats that check packet order (Grim).")
84+
.defaultValue(false)
85+
.build()
86+
);
87+
7388
// Sorting
7489

7590
private final Setting<Boolean> sortingEnabled = sgSorting.add(new BoolSetting.Builder()
@@ -104,13 +119,6 @@ public class InventoryTweaks extends Module {
104119
.build()
105120
);
106121

107-
private final Setting<Boolean> uncapBundleScrolling = sgGeneral.add(new BoolSetting.Builder()
108-
.name("uncap-bundle-scrolling")
109-
.description("Whether to uncap the bundle scrolling feature to let you select any item.")
110-
.defaultValue(true)
111-
.build()
112-
);
113-
114122
// Anti drop
115123

116124
private final Setting<List<Item>> antiDropItems = sgAntiDrop.add(new ItemListSetting.Builder()
@@ -466,6 +474,10 @@ public boolean uncapBundleScrolling() {
466474
return isActive() && uncapBundleScrolling.get();
467475
}
468476

477+
public boolean frameInput() {
478+
return isActive() && frameInput.get();
479+
}
480+
469481
public boolean canSteal(ScreenHandler handler) {
470482
try {
471483
return (stealScreens.get().contains(handler.getType()));

0 commit comments

Comments
 (0)