Skip to content

Instantly share code, notes, and snippets.

@lowercasebtw
Last active November 2, 2025 19:27
Show Gist options
  • Select an option

  • Save lowercasebtw/664cadad36aa62abfb5282dfc3f3c10e to your computer and use it in GitHub Desktop.

Select an option

Save lowercasebtw/664cadad36aa62abfb5282dfc3f3c10e to your computer and use it in GitHub Desktop.
private boolean shouldRestoreSprint = false;
// In LocalPlayer#tick, injected after ``super.tick``
private void fixMC152728() {
if (shouldRestoreSprint && !this.canResumeSprinting()) {
shouldRestoreSprint = false;
}
if (this.isSprinting() && this.isUsingItem()) {
ItemStack stack = this.getUseItem();
if (!stack.isEmpty() && !stack.getOrDefault(DataComponents.USE_EFFECTS, UseEffects.DEFAULT).canSprint()) {
this.setSprinting(false);
shouldRestoreSprint = true;
}
} else if (shouldRestoreSprint && !this.isUsingItem()) {
this.setSprinting(true);
shouldRestoreSprint = false;
}
}
private boolean canResumeSprinting() {
return this.input.hasForwardImpulse() &&
this.isSprintingPossible(this.getAbilities().flying) &&
(!this.isFallFlying() || this.isUnderWater()) &&
(!this.isMovingSlowly() || this.isUnderWater());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment