Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Options for Sprinting #772

Merged
merged 9 commits into from
Dec 15, 2023

Conversation

ThisTestUser
Copy link
Contributor

@ThisTestUser ThisTestUser commented Jan 30, 2023

Adds a few more options in AutoSprint to allow for some non-vanilla behaviors:

  • Sprinting in all directions
  • Sprinting when on low hunger (hunger will still be lost) (blocked by anticheats)
  • Sprinting while attacking

Note: This PR must be patched if downgrading to 1.19.2. See ClientPlayerEntityMixin.java at ThisTestUser@54ae5fb for more information.

@Alexander01998 Alexander01998 added type:enhancement New feature or request area:settings Improves the settings of existing features. category:movement labels Oct 15, 2023
Copy link

This pull request has been open for a while with no recent activity. If you're still working on this or waiting for a review, please add a comment or commit within the next 7 days to keep it open. Otherwise, the pull request will be automatically closed to free up time for other tasks.

Pull requests should be closed if:

  • They have been superseded by another pull request
  • They are out of scope or don't align with the project
  • They have become obsolete due to other changes
  • They have bugs or conflicts that won't be resolved

Copy link

coderabbitai bot commented Dec 15, 2023

Walkthrough

Walkthrough

The AutoSprint feature in WurstClient has been enhanced with new settings to provide more control over when the player automatically sprints. These settings include options to sprint in all directions, while attacking, and even when hungry. The logic for sprinting has been updated to respect these new settings, and the sprinting mechanism now factors in these conditions before enabling sprint. Additionally, attack-related sprinting conditions are now managed within the PlayerEntity attack logic, ensuring sprinting occurs as configured by the player.

Changes

File Path Change Summary
.../hacks/AutoSprintHack.java Added settings for direction, attacking, and hunger sprinting; updated sprinting logic.
.../mixin/ClientPlayerEntityMixin.java Added canSprint method to inject new sprinting conditions.
.../mixin/PlayerEntityMixin.java Modified attack method to include sprinting conditions check.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 676d07a and 1683582.
Files ignored due to filter (1)
  • src/main/resources/wurst.mixins.json
Files selected for processing (3)
  • src/main/java/net/wurstclient/hacks/AutoSprintHack.java (2 hunks)
  • src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (1 hunks)
  • src/main/java/net/wurstclient/mixin/PlayerEntityMixin.java (1 hunks)
Additional comments: 8
src/main/java/net/wurstclient/hacks/AutoSprintHack.java (5)
  • 20-25: The addition of new CheckboxSetting instances for sprint behaviors is consistent with the PR objectives and enhances the mod's functionality.

  • 31-33: Properly adding the new settings to the AutoSprintHack using the addSetting method.

  • 59-62: The onUpdate method correctly checks the allDirections setting to determine if sprinting should be activated, aligning with the PR's intent to allow omnidirectional sprinting.

  • 65-67: The shouldSprintAttack method is correctly implemented to check if the hack is enabled and the attack setting is checked.

  • 70-72: The shouldSprintHungry method is correctly implemented to check if the hack is enabled and the hungry setting is checked.

src/main/java/net/wurstclient/mixin/PlayerEntityMixin.java (3)
  • 22-42: The implementation of the @Redirect annotations appears to correctly conditionally modify the behavior of the attack method based on the shouldSprintAttack method. However, it is important to ensure that the shouldSprintAttack method is robust and handles all necessary conditions, as it now plays a critical role in the attack mechanics.

  • 29-30: Verify that the shouldSprintAttack method properly accounts for all game states and server conditions, especially since sprinting while attacking could potentially trigger anti-cheat systems in multiplayer environments.

  • 19-42: Ensure that the changes in this mixin are compatible with all supported versions of the game, particularly if the mod is intended to be used with version 1.19.2, as mentioned in the PR. Testing across versions or implementing version-specific logic may be necessary.

It doesn't seem to work right now. Using this option would give you the sprinting particles but no actual speed increase.
Unfortunately this setting only works in singleplayer as the PlayerEntityMixin code runs on the server side.
@Alexander01998
Copy link
Member

Hey @ThisTestUser,

Thanks for the pull request! While testing your changes, I've noticed that some of the new AutoSprint settings don't seem to be working as intended:

  1. The "Omnidirectional Sprint" option gives the visual sprint particles but doesn't actually increase the player's speed in any direction other than forward.

  2. The "Attack Sprint" option only works in singleplayer. It appears the relevant code in PlayerEntityMixin is only executed in an instance of ServerPlayerEntity, meaning it's server-side.

I'm removing these settings for now and merging the PR only the working "Hungry Sprint" setting. If you're up for the task of troubleshooting and resolving the issues with the other options, feel free to submit another PR in the future.

@Alexander01998 Alexander01998 added this to the v7.40 milestone Dec 15, 2023
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1683582 and 236bca8.
Files selected for processing (2)
  • src/main/java/net/wurstclient/hacks/AutoSprintHack.java (2 hunks)
  • src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/main/java/net/wurstclient/hacks/AutoSprintHack.java
  • src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java

@Alexander01998 Alexander01998 merged commit ae75d64 into Wurst-Imperium:master Dec 15, 2023
2 checks passed
@Alexander01998 Alexander01998 added the status:merged This pull request has been merged, even if GitHub says otherwise. label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:settings Improves the settings of existing features. category:movement status:merged This pull request has been merged, even if GitHub says otherwise. type:enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants