Skip to content

Commit

Permalink
Add keep sprint setting to the Sprint module
Browse files Browse the repository at this point in the history
closes #4084
  • Loading branch information
Wide-Cat committed May 31, 2024
1 parent 3494a75 commit 49f3305
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -113,6 +112,15 @@ private void onGetOffGroundSpeed(CallbackInfoReturnable<Float> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public enum Mode {
.build()
);

private final Setting<Boolean> 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.");
}
Expand All @@ -60,4 +67,8 @@ private void onTick(TickEvent.Post event) {
case Rage -> sprint();
}
}

public boolean stopSprinting() {
return !isActive() || !keepSprint.get();
}
}

0 comments on commit 49f3305

Please sign in to comment.