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

Commit

Permalink
Crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekiplay committed Mar 28, 2024
1 parent d049c95 commit e126d62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,9 @@ public SprintPlus() {
.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
Expand Up @@ -3,19 +3,19 @@
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.Unique;
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)
@Mixin(value = ClientPlayerEntity.class, priority = 1002)
public abstract class ClientPlayerEntityMixin {
@Shadow
public Input input;
Expand Down Expand Up @@ -46,7 +46,7 @@ private void hookCustomMultiplier(CallbackInfo ci) {
* Hook sprint effect from NoSlow module
*/
@Inject(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"), cancellable = true)
private void hookSprintAffectStart(CallbackInfoReturnable<Boolean> cir) {
private void hookSprintAffectStartF(CallbackInfoReturnable<Boolean> cir) {
if (Modules.get().get(NoSlowPlus.class).isActive()) {
cir.setReturnValue(true);
}
Expand All @@ -56,15 +56,10 @@ 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) {
private boolean hookSprintIgnoreBlindnessF(boolean original) {
SprintPlus sprintPlus = Modules.get().get(SprintPlus.class);
if (sprintPlus == null) { return false; }
return !sprintPlus.shouldIgnoreBlindness() && original;
}

Expand All @@ -73,11 +68,13 @@ private boolean hookOmnidirectionalSprintC(ClientPlayerEntity instance) {
return isOmniWalking(instance);
}

@Unique
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);
if (sprintPlus == null) { return false; }
return sprintPlus.shouldSprintOmnidirectionally() ? modifiedIsWalking : this.isWalking();
}
}

0 comments on commit e126d62

Please sign in to comment.