Skip to content

Commit

Permalink
Merge #772 (AutoSprint hunger setting)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 authored Dec 15, 2023
2 parents 676d07a + 236bca8 commit ae75d64
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/net/wurstclient/hacks/AutoSprintHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@
import net.wurstclient.SearchTags;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.CheckboxSetting;

@SearchTags({"auto sprint"})
public final class AutoSprintHack extends Hack implements UpdateListener
{
private final CheckboxSetting hungry = new CheckboxSetting("Hungry Sprint",
"Sprint even on low hunger.", false);

public AutoSprintHack()
{
super("AutoSprint");
setCategory(Category.MOVEMENT);
addSetting(hungry);
}

@Override
Expand Down Expand Up @@ -48,4 +53,9 @@ public void onUpdate()
if(player.forwardSpeed > 0)
player.setSprinting(true);
}

public boolean shouldSprintHungry()
{
return isEnabled() && hungry.isChecked();
}
}
11 changes: 11 additions & 0 deletions src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ private void afterUpdateNausea(CallbackInfo ci)
tempCurrentScreen = null;
}

/**
* This mixin allows AutoSprint to enable sprinting even when the player is
* too hungry.
*/
@Inject(at = @At("HEAD"), method = "canSprint()Z", cancellable = true)
private void onCanSprint(CallbackInfoReturnable<Boolean> cir)
{
if(WurstClient.INSTANCE.getHax().autoSprintHack.shouldSprintHungry())
cir.setReturnValue(true);
}

/**
* Getter method for what used to be airStrafingSpeed.
* Overridden to allow for the speed to be modified by hacks.
Expand Down

0 comments on commit ae75d64

Please sign in to comment.