From 49f330575973cc2e146efc96ecdf4ec434fe217b Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Fri, 31 May 2024 19:51:23 +0100 Subject: [PATCH] Add keep sprint setting to the Sprint module closes #4084 --- .../meteorclient/mixin/PlayerEntityMixin.java | 16 ++++++++++++---- .../systems/modules/movement/Sprint.java | 11 +++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java index a135ee99e0..8beed23b56 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java @@ -6,14 +6,12 @@ package meteordevelopment.meteorclient.mixin; import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.entity.DropItemsEvent; import meteordevelopment.meteorclient.events.entity.player.ClipAtLedgeEvent; import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.movement.Anchor; -import meteordevelopment.meteorclient.systems.modules.movement.Flight; -import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; -import meteordevelopment.meteorclient.systems.modules.movement.Scaffold; +import meteordevelopment.meteorclient.systems.modules.movement.*; import meteordevelopment.meteorclient.systems.modules.player.Reach; import meteordevelopment.meteorclient.systems.modules.player.SpeedMine; import meteordevelopment.meteorclient.utils.world.BlockUtils; @@ -26,6 +24,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -113,6 +112,15 @@ private void onGetOffGroundSpeed(CallbackInfoReturnable info) { if (speed != -1) info.setReturnValue(speed); } + @WrapWithCondition(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V")) + private boolean keepSprint$setVelocity(PlayerEntity instance, Vec3d vec3d) { + return Modules.get().get(Sprint.class).stopSprinting(); + } + + @WrapWithCondition(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setSprinting(Z)V")) + private boolean keepSprint$setSprinting(PlayerEntity instance, boolean b) { + return Modules.get().get(Sprint.class).stopSprinting(); + } @ModifyReturnValue(method = "getBlockInteractionRange", at = @At("RETURN")) private double modifyBlockInteractionRange(double original) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java index 316e24bcb2..5b8e15e915 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java @@ -37,6 +37,13 @@ public enum Mode { .build() ); + private final Setting keepSprint = sgGeneral.add(new BoolSetting.Builder() + .name("keep-sprint") + .description("Whether to keep sprinting after attacking an entity.") + .defaultValue(false) + .build() + ); + public Sprint() { super(Categories.Movement, "sprint", "Automatically sprints."); } @@ -60,4 +67,8 @@ private void onTick(TickEvent.Post event) { case Rage -> sprint(); } } + + public boolean stopSprinting() { + return !isActive() || !keepSprint.get(); + } }