Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
Sprint+
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekiplay committed Mar 28, 2024
1 parent ccfa896 commit 4dba250
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/nekiplay/meteorplus/MeteorPlusAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public void onInitialize() {
Modules modules = Modules.get();

modules.add(new HologramModule());
modules.add(new SprintPlus());
modules.add(new ChatPrefix());
modules.add(new ChatGPT());
modules.add(new ItemHighlightPlus());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package nekiplay.meteorplus.features.modules.movement;

import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.player.Rotations;

public class SprintPlus extends Module {
public SprintPlus() {
super(Categories.Movement, "sprint+", "Better sprint module.");
}
private final SettingGroup sgGeneral = settings.getDefaultGroup();
private final Setting<Boolean> allDirections = sgGeneral.add(new BoolSetting.Builder()
.name("All-directions")
.defaultValue(false)
.build()
);
private final Setting<Boolean> ignoreBlindness = sgGeneral.add(new BoolSetting.Builder()
.name("Ignore-blindness")
.defaultValue(false)
.build()
);

private final Setting<Boolean> ignoreHunger = sgGeneral.add(new BoolSetting.Builder()
.name("Ignore-hunger")
.defaultValue(false)
.build()
);

public boolean shouldSprintOmnidirectionally() { return isActive() && allDirections.get(); }

public boolean shouldIgnoreBlindness() { return isActive() && ignoreBlindness.get(); }

public boolean shouldIgnoreHunger() { return isActive() && ignoreHunger.get(); }

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
package nekiplay.meteorplus.mixin.minecraft;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.movement.Sprint;
import nekiplay.meteorplus.events.PlayerUseMultiplierEvent;
import nekiplay.meteorplus.features.modules.movement.SprintPlus;
import nekiplay.meteorplus.features.modules.movement.noslow.NoSlowPlus;
import net.minecraft.client.input.Input;
import net.minecraft.client.network.ClientPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = ClientPlayerEntity.class, priority = 1001)
public class ClientPlayerEntityMixin {
public abstract class ClientPlayerEntityMixin {
@Shadow
public Input input;
@Shadow
public abstract boolean isSubmergedInWater();
@Shadow
protected abstract boolean isWalking();

@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z", ordinal = 0))
private void hookCustomMultiplier(CallbackInfo ci) {
final PlayerUseMultiplierEvent playerUseMultiplier = new PlayerUseMultiplierEvent(0.2f, 0.2f);
Expand Down Expand Up @@ -44,4 +51,33 @@ private void hookSprintAffectStart(CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(true);
}
}
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z"))
private boolean hookOmnidirectionalSprintB(ClientPlayerEntity instance) {
return isOmniWalking(instance);
}

@ModifyConstant(method = "canSprint", constant = @Constant(floatValue = 6.0F), slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/HungerManager;getFoodLevel()I", ordinal = 0)))
private float hookSprintIgnoreHunger(float constant) {
SprintPlus sprintPlus = Modules.get().get(SprintPlus.class);
return sprintPlus.shouldIgnoreHunger() ? -1F : constant;
}

@ModifyExpressionValue(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z"))
private boolean hookSprintIgnoreBlindness(boolean original) {
SprintPlus sprintPlus = Modules.get().get(SprintPlus.class);
return !sprintPlus.shouldIgnoreBlindness() && original;
}

@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z"))
private boolean hookOmnidirectionalSprintC(ClientPlayerEntity instance) {
return isOmniWalking(instance);
}

private boolean isOmniWalking(ClientPlayerEntity instance) {
boolean hasMovement = Math.abs(instance.input.movementForward) > 1.0E-5F || Math.abs(instance.input.movementSideways) > 1.0E-5F;
boolean isWalking = (double) Math.abs(instance.input.movementForward) >= 0.8 || (double) Math.abs(instance.input.movementSideways) >= 0.8;
boolean modifiedIsWalking = this.isSubmergedInWater() ? hasMovement : isWalking;
SprintPlus sprintPlus = Modules.get().get(SprintPlus.class);
return sprintPlus.shouldSprintOmnidirectionally() ? modifiedIsWalking : this.isWalking();
}
}

0 comments on commit 4dba250

Please sign in to comment.