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

Add AutoPlaceHack #1048

Closed
wants to merge 2 commits into from
Closed

Add AutoPlaceHack #1048

wants to merge 2 commits into from

Conversation

LilyKensa
Copy link

@LilyKensa LilyKensa commented Aug 8, 2024

Description

Added a simple but cool feature, AutoPlace. This hack allows you to free up your right middle finger when bridging, as it will place the blocks for you when you need to.

When it's enabled, blocks will be placed as long as you aim at side faces of blocks.

Testing

It's working, here's the video
Don't complain about my aiming though, I'm using a very bad mouse right now

Notes

😎 I've applied spotless to match the original coding style.

🤔 Not sure if I need to disable some other hacks like ScaffoldWalk when this hack is turned on?

Copy link

coderabbitai bot commented Aug 8, 2024

Walkthrough

Walkthrough

The recent changes introduce the AutoPlaceHack class to the HackList, enhancing hacking capabilities by automating block placement in Minecraft. This new feature allows players to place blocks more efficiently with configurable placement conditions, improving gameplay and building strategies.

Changes

File Path Change Summary
src/main/java/net/wurstclient/hack/HackList.java Added public final AutoPlaceHack autoPlaceHack = new AutoPlaceHack(); to integrate the new hack into the HackList class.
src/main/java/net/wurstclient/hacks/AutoPlaceHack.java Introduced AutoPlaceHack class extending Hack and implementing UpdateListener. Added configurable settings for block placement and implemented logic in onUpdate.

Sequence Diagram(s)

sequenceDiagram
    participant Player
    participant AutoPlaceHack
    participant GameState

    Player->>AutoPlaceHack: Enable Hack
    AutoPlaceHack->>GameState: Register as UpdateListener
    GameState->>AutoPlaceHack: onUpdate() Triggered
    AutoPlaceHack->>GameState: Check conditions (not in GUI, item is block)
    alt Conditions met
        AutoPlaceHack->>GameState: Place block
        AutoPlaceHack->>Player: Swing hand
    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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e350cb6 and 1ebb8d9.

Files ignored due to path filters (2)
  • src/main/resources/assets/wurst/translations/en_us.json is excluded by !**/*.json
  • src/main/resources/assets/wurst/translations/zh_tw.json is excluded by !**/*.json
Files selected for processing (2)
  • src/main/java/net/wurstclient/hack/HackList.java (1 hunks)
  • src/main/java/net/wurstclient/hacks/AutoPlaceHack.java (1 hunks)
Additional comments not posted (11)
src/main/java/net/wurstclient/hacks/AutoPlaceHack.java (10)

46-49: Event registration looks good.

The onEnable method correctly registers the hack as an UpdateListener.


52-55: Event deregistration looks good.

The onDisable method correctly removes the hack from the UpdateListener events.


60-61: Check for unnecessary screen checks.

The method exits early if MC.currentScreen is an instance of HandledScreen. Ensure this condition is necessary and doesn't inadvertently block functionality.

Verification successful

Screen check is necessary to prevent unintended interactions.

The check for MC.currentScreen instanceof HandledScreen in the AutoPlaceHack is consistent with its use across multiple hacks. This pattern likely prevents automated actions from interfering with user interactions in GUIs, suggesting its necessity.

  • Files with similar checks:
    • src/main/java/net/wurstclient/hacks/AimAssistHack.java
    • src/main/java/net/wurstclient/hacks/RestockHack.java
    • src/main/java/net/wurstclient/hacks/KillauraLegitHack.java
    • src/main/java/net/wurstclient/hacks/TriggerBotHack.java
    • src/main/java/net/wurstclient/hacks/AutoTotemHack.java
    • src/main/java/net/wurstclient/hacks/AutoDropHack.java
    • src/main/java/net/wurstclient/hacks/AutoArmorHack.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the necessity of the screen check in the onUpdate method.

# Test: Search for usages of HandledScreen to understand its role in the codebase.
rg --type java 'HandledScreen'

Length of output: 3114


69-72: Verify block item check logic.

The method checks if the item in hand is a BlockItem. Ensure this logic is correct and necessary for the intended functionality.

Verification successful

Block item check logic is correct and necessary.

The check for BlockItem in the AutoPlaceHack and other similar hacks ensures that the functionality only triggers when the item in hand is a block, which is crucial for their intended operations. This logic is consistently applied across multiple hacks, indicating its necessity.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the logic for checking if the item in hand is a BlockItem.

# Test: Search for BlockItem usage to understand its role and necessity.
rg --type java 'BlockItem'

Length of output: 1198


91-94: Review onlyBelowFeet condition.

The method includes an option to place blocks only below the player's feet. Ensure this condition is correctly implemented and aligns with user expectations.

Verification successful

onlyBelowFeet Condition is Correctly Implemented

The onlyBelowFeet setting restricts block placement to only when the target block is directly below the player's feet, as described: "Only place blocks when target block is 1 block below your feet." The current implementation correctly enforces this behavior.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the logic for the onlyBelowFeet condition in the onUpdate method.

# Test: Search for onlyBelowFeet usage to understand its role and necessity.
rg --type java 'onlyBelowFeet'

Length of output: 321


Script:

#!/bin/bash
# Searching for comments or documentation related to the 'onlyBelowFeet' setting in the codebase.
rg --type java -A 5 'onlyBelowFeet'

Length of output: 1634


96-103: Review interaction logic.

The method handles block interaction and item use cooldown. Ensure this logic is correctly implemented and doesn't conflict with other features.

Verification successful

Interaction Logic Verified

The interaction logic and item use cooldown in AutoPlaceHack.java are consistent with other parts of the codebase. The itemUseCooldown is uniformly set to 4 across different hacks, indicating a standardized approach. The logic does not conflict with other features.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the interaction logic and item use cooldown in the onUpdate method.

# Test: Search for interactionManager usage to understand its role and potential conflicts.
rg --type java 'interactionManager'

Length of output: 7212


Script:

#!/bin/bash
# Description: Search for itemUseCooldown usage to verify consistency and potential conflicts.
rg --type java 'itemUseCooldown'

Length of output: 2186


37-43: Ensure settings are correctly initialized.

The constructor initializes the hack with two settings: Only Below Feet and Always FastPlace. Ensure these settings are correctly reflected in the user interface and function as intended.

Verification successful

Settings are correctly initialized in AutoPlaceHack.

The settings Only Below Feet and Always FastPlace are properly initialized as CheckboxSetting instances in the AutoPlaceHack class. They are set up with the expected names and descriptions. No further action is needed regarding their initialization.

  • File: src/main/java/net/wurstclient/hacks/AutoPlaceHack.java
  • Lines: Initialization of onlyBelowFeet and fastPlace.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization and usage of settings in AutoPlaceHack.

# Test: Search for the usage of settings in the codebase to ensure they are correctly reflected in the UI.
rg --type java 'CheckboxSetting\("Only Below Feet"\)'
rg --type java 'CheckboxSetting\("Always FastPlace"\)'

Length of output: 112


Script:

#!/bin/bash
# Use ast-grep to search for the implementation of the constructor in AutoPlaceHack to see how settings are initialized.
ast-grep --lang java --pattern 'class AutoPlaceHack {
  $$$
  public AutoPlaceHack() {
    $$$
  }
  $$$
}'

Length of output: 109


Script:

#!/bin/bash
# Use rg to search for the definition of the AutoPlaceHack class and its constructor.
rg 'class AutoPlaceHack' -A 10 --type java

Length of output: 1080


83-84: Ensure canBeClicked logic is correct.

The method checks if a block can be clicked using BlockUtils.canBeClicked. Ensure this logic is necessary and correctly implemented.

Verification successful

canBeClicked Logic is Correct and Necessary

The canBeClicked method in BlockUtils checks if a block's outline shape is not empty, which is a valid criterion for determining if a block can be interacted with. This logic is used in multiple parts of the codebase, confirming its necessity and correctness.

  • Implementation: BlockUtils.canBeClicked returns true if getOutlineShape(pos) != VoxelShapes.empty().
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the logic for checking if a block can be clicked.

# Test: Search for canBeClicked usage to understand its role and necessity.
rg --type java 'BlockUtils.canBeClicked'

Length of output: 1784


Script:

#!/bin/bash
# Search for the implementation of the canBeClicked method in BlockUtils
ast-grep --lang java --pattern 'class BlockUtils { $$$ canBeClicked($_) { $$$ } $$$ }'

Length of output: 88


Script:

#!/bin/bash
# Search for the definition of the canBeClicked method in BlockUtils
rg --type java 'canBeClicked' -A 5

Length of output: 12304


78-81: Review block side checks.

The method checks if the block side is not UP or DOWN. Ensure this condition is necessary and aligns with the intended functionality.

Verification successful

Block side checks are likely intentional and necessary.

The checks for UP and DOWN sides in AutoPlaceHack.java appear to be part of a series of conditions to ensure correct block placement. This likely prevents placing blocks on the top or bottom sides, which could interfere with gameplay or cause unintended behavior. The surrounding code supports this interpretation.

  • Lines 78-81 in AutoPlaceHack.java: Ensure that these checks align with the intended functionality of the hack.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the necessity of block side checks in the onUpdate method.

# Test: Search for usages of block sides to understand their role in the codebase.
rg --type java 'blockHitResult.getSide()'

Length of output: 497


Script:

#!/bin/bash
# Search for comments or documentation in the AutoPlaceHack.java file that might explain the purpose of the block side check.
rg --type java --context 5 'blockHitResult.getSide()' src/main/java/net/wurstclient/hacks/AutoPlaceHack.java

Length of output: 771


Script:

#!/bin/bash
# Search for method definitions in AutoPlaceHack.java to understand the context of the block side check.
ast-grep --lang java --pattern 'class AutoPlaceHack { $$$ }'

Length of output: 62


63-64: Consider the impact of itemUseCooldown.

The method checks MC.itemUseCooldown and exits if it's non-zero and fastPlace is unchecked. Ensure this logic aligns with the intended functionality and doesn't conflict with other features.

Verification successful

Verification of itemUseCooldown Logic in AutoPlaceHack: No Issues Found

The logic involving itemUseCooldown in AutoPlaceHack is consistent with the intended functionality. The use of fastPlace to bypass cooldowns is a standard feature, allowing users to opt for faster actions. This does not conflict with other features that rely on itemUseCooldown.

  • The fastPlace setting is a user-controlled option that allows bypassing the cooldown.
  • itemUseCooldown is a shared resource, but the logic in AutoPlaceHack respects its intended use.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the logic involving itemUseCooldown in the onUpdate method.

# Test: Search for itemUseCooldown usage to understand its role and potential conflicts.
rg --type java 'itemUseCooldown'

Length of output: 2186


Script:

#!/bin/bash
# Search for the implementation of fastPlace and its isChecked method to understand its role.
ast-grep --lang java --pattern 'class $_ { $$$ fastPlace; $$$ }'

# Search for any documentation or comments related to fastPlace and itemUseCooldown.
rg --type java 'fastPlace|itemUseCooldown' -A 3 -B 3

Length of output: 18254

src/main/java/net/wurstclient/hack/HackList.java (1)

52-52: Integration of AutoPlaceHack looks good.

The addition of AutoPlaceHack to the HackList is correctly implemented. Ensure that this integration is tested and functions as expected with other hacks.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1ebb8d9 and 76a5b03.

Files ignored due to path filters (2)
  • src/main/resources/assets/wurst/translations/en_us.json is excluded by !**/*.json
  • src/main/resources/assets/wurst/translations/zh_tw.json is excluded by !**/*.json
Files selected for processing (1)
  • src/main/java/net/wurstclient/hack/HackList.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/java/net/wurstclient/hack/HackList.java

@LilyKensa LilyKensa closed this Aug 9, 2024
@LilyKensa LilyKensa mentioned this pull request Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant