Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Fix for cant disable sprint scaffold issue #847 #850

Merged
merged 4 commits into from
Nov 25, 2024
Merged

Conversation

Kefpull
Copy link

@Kefpull Kefpull commented Nov 21, 2024

Description

Added: (sprint module): Disable While Scaffold
Added: (scaffold module): Cancel Sprint At Start

When the "sprint" module is enabled (particularly the "legit" mode), it effectively overrides whatever is set in the sprint options in "scaffold". While this is fine for the sprint scaffolds, if you don't want a sprint scaffold then you would be out of luck, as enabling scaffold also normally preserves your sprint state. So I added 2 options, one to stop sprint from overriding scaffold's options and another to remove the sprint state when scaffold is first aenabled.

Testing

https://github.com/Kefpull/Kef_Raven-XD/releases/download/development/raven-XD.jar

References

issue #847 #847

Summary by CodeRabbit

  • New Features

    • Introduced a new setting to disable sprinting while the scaffold module is active.
    • Added a setting to cancel sprinting when the scaffold module is enabled.
  • Bug Fixes

    • Improved sprinting behavior control when interacting with the scaffold module, enhancing overall user experience.

Added logo_small so that you can have the logo in the Minecraft Launcher.
This was annoying me really bad, so I decided to go ahead and fix it.

Added: (sprint module): Disable While Scaffold

Added: (scaffold module): Cancel Sprint At Start

NOTE: Double-tapping w to sprint still works for some reason. If anyone knows why this happens and how to stop it please feel free to edit the pr.
Copy link

coderabbitai bot commented Nov 21, 2024

Caution

Review failed

The pull request is closed.

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes involve modifications to the Sprint and Scaffold classes in the keystrokesmod package. A new ButtonSetting called disableWhileScaffold has been added to the Sprint class, allowing sprinting to be disabled when the scaffold module is active. Similarly, the Scaffold class introduces a cancelSprintAtStart setting to cancel sprinting upon activation of the scaffold module. The logic in both classes has been adjusted to incorporate these settings, refining the control over sprinting behavior in relation to the scaffold module.

Changes

File Path Change Summary
src/main/java/keystrokesmod/module/impl/movement/Sprint.java Added ButtonSetting disableWhileScaffold to control sprinting when scaffold module is active. Modified p(PlayerTickEvent e) method to adjust sprint key state based on the new setting.
src/main/java/keystrokesmod/module/impl/world/Scaffold.java Introduced ButtonSetting cancelSprintAtStart to cancel sprinting when scaffold module is enabled. Modified onEnable method to handle this setting and improve readability.

Sequence Diagram(s)

sequenceDiagram
    participant Player
    participant Sprint
    participant Scaffold

    Player->>Scaffold: Enable Scaffold Module
    alt cancelSprintAtStart is toggled
        Scaffold->>Player: Set sprinting state to false
    end
    Player->>Sprint: Check if sprinting is allowed
    alt disableWhileScaffold is toggled
        Sprint->>Player: Set sprint key state to false
    else
        Sprint->>Player: Set sprint key state to true
    end
Loading

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 your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or auto anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Kefpull
Copy link
Author

Kefpull commented Nov 21, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Nov 21, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 5272ca3 and 6bbbd10.

⛔ Files ignored due to path filters (1)
  • logo/logo_small.png is excluded by !**/*.png
📒 Files selected for processing (2)
  • src/main/java/keystrokesmod/module/impl/movement/Sprint.java (3 hunks)
  • src/main/java/keystrokesmod/module/impl/world/Scaffold.java (3 hunks)
🔇 Additional comments (7)
src/main/java/keystrokesmod/module/impl/movement/Sprint.java (4)

7-7: LGTM!

The ButtonSetting import is correctly added to support the new setting.


20-20: LGTM!

The field is properly declared with appropriate access modifiers and a descriptive name.


49-56: ⚠️ Potential issue

Add null check and consider other sprint conditions.

There are several potential issues with this implementation:

  1. Missing null check for ModuleManager.scaffold
  2. The else branch unconditionally enables sprinting, which might override other sprint conditions
  3. Inconsistent indentation

Consider this safer implementation:

-            if(ModuleManager.scaffold.isEnabled() && disableWhileScaffold.isToggled()) {
-                KeyBinding.setKeyBindState(mc.gameSettings.keyBindSprint.getKeyCode(), false);
-            }
-            else {
-                KeyBinding.setKeyBindState(mc.gameSettings.keyBindSprint.getKeyCode(), true);
-            }
+            boolean shouldDisableSprint = ModuleManager.scaffold != null 
+                && ModuleManager.scaffold.isEnabled() 
+                && disableWhileScaffold.isToggled();
+            
+            if (shouldDisableSprint) {
+                KeyBinding.setKeyBindState(mc.gameSettings.keyBindSprint.getKeyCode(), false);
+            } else {
+                // Preserve existing sprint state if not explicitly disabled
+                boolean canSprint = MoveUtil.isMoving() && !stopSprint;
+                KeyBinding.setKeyBindState(mc.gameSettings.keyBindSprint.getKeyCode(), canSprint);
+            }

Let's verify the scaffold module initialization:


Line range hint 63-77: Verify interaction with omni mode.

The new scaffold-related sprint controls might interfere with the omni mode functionality. Please verify that the changes don't affect sprinting behavior when in omni mode.

✅ Verification successful

Based on the search results, I can see that the Sprint module's omni mode implementation is properly handled in the switch statement and doesn't interfere with the scaffold-related sprint controls. The omni mode functionality is contained within its own switch block and only modifies the yaw when enabled, while the sprint control is handled separately after the switch block. Here's my final response:

The omni mode implementation is safe and independent of scaffold controls

The omni mode functionality is properly encapsulated in its own switch block (lines 64-70) and only affects yaw rotation when enabled. The sprint control that follows (lines 72-73) is independent of this logic and won't interfere with omni mode's operation. The changes maintain clean separation of concerns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential interactions between omni mode and scaffold
ast-grep --pattern 'case $_:
  $$$
  mc.thePlayer.setSprinting($_);
  $$$'

Length of output: 76


Script:

#!/bin/bash
# Let's try a different approach to analyze the omni mode implementation
# First, let's find all references to omni mode
rg -i "omnimode" -B 2 -A 2

# Also check for sprint-related code
rg "setSprinting" -B 2 -A 2

# And check for any switch statements related to sprint modes
ast-grep --pattern 'switch ($$$) {
  $$$
  case $_: 
    $$$
}'

Length of output: 123819

src/main/java/keystrokesmod/module/impl/world/Scaffold.java (3)

96-96: LGTM! Field declaration follows class conventions.

The new cancelSprintAtStart setting is properly declared as private final and follows the existing naming pattern.


246-252: LGTM! Implementation is clean and effective.

The code properly implements the sprint cancellation functionality:

  1. Checks if the setting is enabled
  2. Disables sprinting if needed
  3. Uses proper bracing and follows the code style

250-251: Verify interaction with Sprint module's disableWhileScaffold setting.

Let's ensure there are no conflicts between this new setting and the Sprint module's disableWhileScaffold setting.

//Only needs to work in legit mode
to
// This setting is only applicable in legit mode as omni mode handles sprinting differently

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Kefpull Kefpull marked this pull request as ready for review November 21, 2024 15:49
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.

Actionable comments posted: 1

🧹 Outside diff range comments (1)
src/main/java/keystrokesmod/module/impl/movement/Sprint.java (1)

Line range hint 1-85: Document module interactions.

Consider adding class-level documentation explaining the interaction between Sprint and Scaffold modules, particularly how the disableWhileScaffold setting works in conjunction with Scaffold's cancelSprintAtStart setting. This would help future maintainers understand the relationship between these modules.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 6bbbd10 and 45a08a0.

📒 Files selected for processing (1)
  • src/main/java/keystrokesmod/module/impl/movement/Sprint.java (3 hunks)
🔇 Additional comments (2)
src/main/java/keystrokesmod/module/impl/movement/Sprint.java (2)

7-7: LGTM!

The ButtonSetting import is correctly added and necessary for the new functionality.


20-20: LGTM!

The field declaration follows good practices with appropriate access modifiers and naming.

@xia-mc xia-mc changed the base branch from master to dev November 25, 2024 15:25
@xia-mc xia-mc merged commit 6c9e3b5 into xia-mc:dev Nov 25, 2024
1 check failed
@coderabbitai coderabbitai bot mentioned this pull request Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants