Skip to content

Conversation

arvi18
Copy link

@arvi18 arvi18 commented Sep 2, 2025

Type of change

  • Bug fix
  • New feature

Description

A summary of the changes along with the reasoning behind the changes.

Related issues

Mention any issues that this pr relates to.

How Has This Been Tested?

Videos or screenshots of the changes if applicable.

Checklist:

  • My code follows the style guidelines of this project.
  • I have added comments to my code in more complex areas.
  • I have tested the code in both development and production environments.

Summary by CodeRabbit

  • New Features
    • Added an Auto-Select mode to Nuker that targets the exact block type you’re aiming at and restricts breaking to that type.
    • The selected block type is remembered while the mode is active and shown for easier confirmation.
  • UX Improvements
    • On activation, if you’re not aiming at a block, the mode won’t select anything and a warning is shown.
    • Auto-Select resets cleanly when the module is turned off.

Copy link

coderabbitai bot commented Sep 2, 2025

Walkthrough

Adds an AutoSelect mode to Nuker. On activation, it captures the block under the crosshair and restricts breaking to that block type. Deactivation clears the selection. The block-iteration predicate now filters by the auto-selected block when AutoSelect is active. Exposes a getter for the selected block and extends the ListMode enum.

Changes

Cohort / File(s) Summary
World/Nuker AutoSelect
src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java
Added AutoSelect mode: crosshair-target-based block capture on activate, cleared on deactivate; updated block filter predicate to honor AutoSelect; introduced autoSelectBlock field, new enum value ListMode.AutoSelect, and public Block getAutoSelectBlock(); imported BlockHitResult and HitResult.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Player
  participant Nuker
  participant MC as Minecraft Client
  participant BI as BlockIterator

  Player->>Nuker: Activate (ListMode=AutoSelect)
  Nuker->>MC: Read crosshairTarget
  alt crosshairTarget is BLOCK
    MC-->>Nuker: BlockHitResult(pos)
    Nuker->>Nuker: autoSelectBlock = world.getBlockState(pos).getBlock()
  else not a block
    MC-->>Nuker: Non-block HitResult
    Nuker->>Nuker: autoSelectBlock = null
    Nuker->>Player: Warn: no block selected
  end

  loop Iteration
    BI->>Nuker: Predicate(state, pos)
    alt ListMode == AutoSelect
      alt autoSelectBlock != null and state.block == autoSelectBlock
        Nuker-->>BI: true
      else
        Nuker-->>BI: false
      end
    else Other modes
      Nuker-->>BI: evaluate whitelist/blacklist as before
    end
  end

  Player->>Nuker: Deactivate
  alt ListMode == AutoSelect
    Nuker->>Nuker: autoSelectBlock = null
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I peered through sights with twitching ear,
“That block!” I thumped—crystal clear.
The Nuker nods, selects my pick,
One tasty target, gone so quick.
When dusk descends, I hop away—
AutoSelect rests till next play. 🐇⛏️

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch clone-feature/nuker-auto-select

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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 anywhere in the PR title to generate the title automatically.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @arvi18, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Nuker module by introducing an AutoSelect mode. This new feature streamlines the block targeting process, allowing users to automatically select and focus the Nuker on the specific block type they are currently looking at, improving convenience and efficiency during gameplay.

Highlights

  • New AutoSelect Mode: Introduced an "AutoSelect" option within the Nuker module's ListMode, allowing the module to automatically target the block currently aimed at by the player.
  • Dynamic Block Selection: When AutoSelect mode is enabled, the Nuker now identifies and stores the block type the player is looking at upon activation, and subsequently only targets blocks of that specific type.
  • Module Lifecycle Integration: Added logic to the onActivate method to capture the targeted block and to the onDeactivate method to clear the auto-selected block, ensuring proper state management.
  • Targeting Logic Update: Modified the block iteration and filtering logic to incorporate the new AutoSelect mode, ensuring only the chosen block type is considered for breaking.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

refacto-test bot commented Sep 2, 2025

Nuker Module Auto-Select Mode

TL;DR: Added an "AutoSelect" mode to the Nuker module that allows targeting specific blocks by looking at them.


Refacto PR Summary

Enhanced the Nuker module with a new AutoSelect mode that dynamically targets blocks based on player's crosshair.
This PR adds a third option to the existing ListMode enum (alongside Whitelist and Blacklist) that allows players to automatically target blocks of the same type as what they're looking at when activating the module. The implementation stores the targeted block in a new autoSelectBlock field, properly handles activation/deactivation states, and integrates with the existing block filtering logic. This improves usability by eliminating the need to manually configure block lists for common mining operations.

Change Highlights

Click to expand
  • Added new autoSelectBlock field to store the currently targeted block type
  • Enhanced onActivate() to detect and store the block under crosshair when using AutoSelect mode
  • Added onDeactivate() to clean up the selected block reference when module is disabled
  • Modified block filtering logic to support the new AutoSelect mode alongside existing Whitelist/Blacklist modes
  • Added a getter method getAutoSelectBlock() for GUI display purposes
  • Added necessary imports for BlockHitResult and HitResult classes

Sequence Diagram

sequenceDiagram
    participant User
    participant Nuker as Nuker Module
    participant World as Minecraft World
    
    User->>Nuker: Activate module (with AutoSelect)
    Nuker->>World: Get block at crosshair position
    World-->>Nuker: Return block type
    Nuker->>Nuker: Store autoSelectBlock
    
    loop Every tick
        Nuker->>World: Scan blocks in range
        World-->>Nuker: Return block positions
        Nuker->>Nuker: Filter blocks matching autoSelectBlock
        Nuker->>World: Break matching blocks
    end
    
    User->>Nuker: Deactivate module
    Nuker->>Nuker: Clear autoSelectBlock
Loading

Testing Guide

Click to expand
  1. Enable the Nuker module and set ListMode to "AutoSelect"
  2. Look at a specific block type (e.g., stone, dirt) and activate the module
  3. Verify that only blocks of the same type as what you were looking at are being targeted
  4. Test edge case: activate without looking at any block - should display a warning message
  5. Change target by deactivating, looking at a different block type, and reactivating
  6. Verify that switching to other list modes (Whitelist/Blacklist) works as expected

@arvi18
Copy link
Author

arvi18 commented Sep 2, 2025

/refacto-test

Copy link

refacto-test bot commented Sep 2, 2025

Refacto is reviewing this PR. Please wait for the review comments to be posted.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an 'Auto-Select' mode to the Nuker module, allowing it to target the block currently in the player's crosshairs. The implementation is well-structured, including proper setup on activation and cleanup on deactivation. The refactoring from multiple if statements to a switch for handling list modes improves code clarity. I've suggested one improvement to enhance user experience when activating the module without a target block.

Comment on lines +279 to +280
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");

Choose a reason for hiding this comment

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

high

When AutoSelect mode is enabled but the player is not looking at a block, the module currently shows a warning and remains active without performing any action. This can be confusing for the user, who might not notice the warning and wonder why the module isn't working.

A better approach would be to provide clearer feedback by showing an error message and automatically deactivating the module. This makes it explicit that the activation failed and why.

Suggested change
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");
error("You must be looking at a block to use Auto-Select. Deactivating.");
toggle();

Copy link

refacto-test bot commented Sep 2, 2025

Code Review: Nuker AutoSelect Implementation

👍 Well Done
Proper Resource Cleanup

AutoSelect block reference properly cleared on deactivation preventing memory leaks.

User Feedback Added

Warning message added when no block targeted improves user experience.

Efficient Block Selection

The AutoSelect implementation efficiently stores selected block without redundant processing.

📌 Files Processed
  • src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java
📝 Additional Comments
src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java (5)
Inconsistent Block Selection

Block selection occurs only once at activation. If user changes target after activation, selection won't update, creating unexpected behavior.

Standards:

  • ISO-IEC-25010-Functional-Correctness-Appropriateness
  • ISO-IEC-25010-Reliability-Maturity
Block Lookup Optimization

The equals() comparison for block matching is performed for every block in range. For large ranges with many blocks, this could become a performance bottleneck. Consider using identity comparison (==) if possible for Block objects, which would be more efficient than equals() method calls in this high-frequency operation.

Standards:

  • ISO-IEC-25010-Performance-Time-Behaviour
  • Algorithm-Opt-Object-Comparison
Long Method Complexity

BlockIterator lambda contains complex nested conditionals with multiple responsibilities. This violates SRP by combining shape checking, block validation, mode handling, and list filtering in one method, making future modifications error-prone.

Standards:

  • SOLID-SRP
  • Clean-Code-Functions
Redundant Warning Message

Warning message displays on every activation without a targeted block, which could create excessive console spam. Consider showing this only when user explicitly switches to AutoSelect mode while active.

Standards:

  • Logic-Verification-User-Experience
  • Business-Rule-Validation
Target Selection Validation

AutoSelect mode stores target block without validation beyond type checking. An attacker could potentially manipulate targeting to select restricted blocks. Consider adding allowlist validation for sensitive block types.

Standards:

  • CWE-284
  • OWASP-A01

Comment on lines +273 to +282
if (listMode.get() == ListMode.AutoSelect) {
HitResult hitResult = mc.crosshairTarget;
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
} else {
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");
}
}
Copy link

Choose a reason for hiding this comment

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

Missing Null Check

Missing null check for mc.world before accessing it. If world is null, this will cause NullPointerException when trying to get block state.

Standards
  • ISO-IEC-25010-Reliability-Fault-Tolerance
  • ISO-IEC-25010-Functional-Correctness-Appropriateness
  • DbC-Preconditions

Comment on lines +273 to +282
if (listMode.get() == ListMode.AutoSelect) {
HitResult hitResult = mc.crosshairTarget;
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
} else {
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");
}
}
Copy link

Choose a reason for hiding this comment

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

Missing Activation Check

The AutoSelect block targeting logic executes unconditionally on module activation without checking if the world and player are initialized. This could cause NullPointerException if module activates during world loading or menu screens.

Standards
  • Logic-Verification-Null-Safety
  • Business-Rule-Validation
  • Algorithm-Correctness-Preconditions

Comment on lines +285 to 290
@Override
public void onDeactivate() {
if (listMode.get() == ListMode.AutoSelect) {
autoSelectBlock = null;
}
}
Copy link

Choose a reason for hiding this comment

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

Missing Reset Logic

onDeactivate() only resets autoSelectBlock for AutoSelect mode but ignores other state variables. This creates inconsistent state management where some fields are reset conditionally while others aren't reset at all.

Standards
  • Clean-Code-Consistency
  • Design-Pattern-State

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

🧹 Nitpick comments (6)
src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java (6)

187-187: Make nullability explicit for autoSelectBlock.

autoSelectBlock can be null; annotate for clarity and tooling.

Apply:

-    private Block autoSelectBlock = null; // Internal field to store the selected block for AutoSelect mode
+    @org.jetbrains.annotations.Nullable
+    private Block autoSelectBlock; // Null when no selection captured

206-209: Color defaults change—double-check contrast/theme fit.

Minor: ensure these RGBA values read well in light/dark themes and are consistent with other modules.

Also applies to: 212-216


285-290: Always clear selection on deactivate.

Clearing regardless of current listMode simplifies state and avoids stale UI.

Apply:

-    public void onDeactivate() {
-        if (listMode.get() == ListMode.AutoSelect) {
-            autoSelectBlock = null;
-        }
-    }
+    public void onDeactivate() {
+        autoSelectBlock = null;
+    }

375-426: AutoSelect predicate: prefer BlockState.isOf; review UniformCube boundary.

  • Use BlockState.isOf for identity checks (clearer and safer than equals on Block).
  • UniformCube uses chebyshevDist >= range; this excludes the boundary layer. Confirm intended (off-by-one?). If inclusion is desired, switch to >.

Apply:

-                        case AutoSelect -> {
-                            if (autoSelectBlock == null || !blockState.getBlock().equals(autoSelectBlock))
-                                return;
-                        }
+                        case AutoSelect -> {
+                            if (autoSelectBlock == null || !blockState.isOf(autoSelectBlock)) return;
+                        }

If boundary should be inclusive:

-                            if (chebyshevDist(mc.player.getBlockPos().getX(), mc.player.getBlockPos().getY(),
-                                    mc.player.getBlockPos().getZ(), blockPos.getX(), blockPos.getY(),
-                                    blockPos.getZ()) >= range.get())
+                            if (chebyshevDist(mc.player.getBlockPos().getX(), mc.player.getBlockPos().getY(),
+                                    mc.player.getBlockPos().getZ(), blockPos.getX(), blockPos.getY(),
+                                    blockPos.getZ()) > range.get())
                                 return;

496-500: Getter can return null—annotate.

Expose nullability for callers (HUD/GUI).

Apply:

-    public Block getAutoSelectBlock() {
+    public @org.jetbrains.annotations.Nullable Block getAutoSelectBlock() {
         return autoSelectBlock;
     }

501-505: Enum extension: confirm config compatibility.

Adding AutoSelect is fine; verify enum values are serialized by name (not ordinal) so existing configs remain valid.

If ordinals are used anywhere, append-only at end is safest; otherwise add a migration. Also consider updating the “Selection mode.” description to mention AutoSelect captures the block at activation.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8a74ba3 and 692621f.

📒 Files selected for processing (1)
  • src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java (2)
src/main/java/meteordevelopment/meteorclient/utils/world/BlockIterator.java (1)
  • BlockIterator (25-112)
src/main/java/meteordevelopment/meteorclient/utils/Utils.java (1)
  • Utils (75-630)
🔇 Additional comments (1)
src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java (1)

26-27: Correct imports for crosshair targeting.

Using BlockHitResult and HitResult is appropriate for reading the crosshair target.

Comment on lines +273 to +283
if (listMode.get() == ListMode.AutoSelect) {
HitResult hitResult = mc.crosshairTarget;
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
} else {
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");
}
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard onActivate with Utils.canUpdate to prevent NPEs.

onActivate can be triggered when world/player is null (e.g., main menu, early join). Add a guard.

Apply:

     public void onActivate() {
         firstBlock = true;
         timer = 0;
         noBlockTimer = 0;
 
-        if (listMode.get() == ListMode.AutoSelect) {
+        if (!Utils.canUpdate()) {
+            autoSelectBlock = null;
+            return;
+        }
+        if (listMode.get() == ListMode.AutoSelect) {
             HitResult hitResult = mc.crosshairTarget;
             if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
                 BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
                 autoSelectBlock = mc.world.getBlockState(pos).getBlock();
             } else {
                 autoSelectBlock = null;
                 warning("No block is being targeted for auto-select mode.");
             }
         }
     }

Optional: capture selection when switching listMode to AutoSelect while enabled (via an onChanged callback), so users don’t have to toggle the module.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (listMode.get() == ListMode.AutoSelect) {
HitResult hitResult = mc.crosshairTarget;
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
} else {
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");
}
}
}
public void onActivate() {
firstBlock = true;
timer = 0;
noBlockTimer = 0;
if (!Utils.canUpdate()) {
autoSelectBlock = null;
return;
}
if (listMode.get() == ListMode.AutoSelect) {
HitResult hitResult = mc.crosshairTarget;
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
} else {
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");
}
}
}
🤖 Prompt for AI Agents
In src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java
around lines 273 to 283, onActivate can run when mc/world/player are null
causing NPEs; add a guard using Utils.canUpdate() at the start of onActivate
(return early if false) before accessing mc.crosshairTarget/world/player, then
perform the AutoSelect logic only when the guard passes. Additionally
(optional), register an onChanged callback for listMode to run the same
selection logic when switching to AutoSelect while the module is enabled so
users don’t need to toggle the module to capture the current targeted block.

@visz11
Copy link
Collaborator

visz11 commented Sep 11, 2025

/refacto-test

Copy link

refacto-test bot commented Sep 11, 2025

Refacto is reviewing this PR. Please wait for the review comments to be posted.

Copy link

refacto-test bot commented Sep 11, 2025

Code Review: Nuker AutoSelect Implementation

👍 Well Done
Proper Error Handling

Warning message when no block targeted prevents silent failure.

Clean State Management

AutoSelect state properly cleared on module deactivation.

Feature Implementation Completeness

AutoSelect mode properly captures targeted block and maintains state throughout module lifecycle.

Proper Input Validation

Added validation for AutoSelect mode when no block is targeted.

📌 Files Processed
  • src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java
📝 Additional Comments
src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java (5)
Optimize Block Iteration

The block iteration process performs multiple conditional checks for each block in range. Consider early-exit optimization by checking the most restrictive conditions first (like AutoSelect block matching) before performing distance calculations. This would reduce unnecessary calculations when using AutoSelect mode, especially in dense areas with many blocks.

Standards:

  • ISO-IEC-25010-Performance-Time-Behaviour
  • Algorithm-Opt-Early-Exit
Incomplete Switch Logic

Switch statement lacks a default case to handle potential future ListMode enum values. If new modes are added without updating this switch, the logic will silently fall through without applying any filtering, potentially breaking the module's behavior.

Standards:

  • Logic-Verification-Completeness
  • Control-Flow-Exhaustiveness
Cache Player Position

Multiple calls to mc.player.getBlockPos() within the iteration lambda could be inefficient. Consider caching the player's BlockPos before the iteration to avoid repeated method calls for each block checked. This would reduce overhead in the hot path, especially when scanning large areas.

Standards:

  • ISO-IEC-25010-Performance-Resource-Utilization
  • Algorithm-Opt-Hot-Path
Extraction Opportunity

Block selection logic could be extracted to a separate method for better organization and potential reuse in other contexts.

Standards:

  • Clean-Code-Method-Extraction
  • SOLID-SRP
Missing Rate Limiting

AutoSelect implementation lacks rate limiting when selecting target blocks. Could allow rapid switching between different block types, potentially bypassing server-side anti-cheat mechanisms.

Standards:

  • CWE-770
  • OWASP-A04

Comment on lines +275 to +277
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
Copy link

Choose a reason for hiding this comment

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

Missing Null Check

Missing null check for mc.world before accessing it. If world is null, NullPointerException will crash the client.

Suggested change
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK && mc.world != null) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
Standards
  • ISO-IEC-25010-Reliability-Fault-Tolerance
  • ISO-IEC-25010-Functional-Correctness-Appropriateness
  • DbC-Precondition

Comment on lines +274 to +281
HitResult hitResult = mc.crosshairTarget;
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
} else {
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");
}
Copy link

Choose a reason for hiding this comment

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

Missing Error Handling

Warning is displayed when no block is targeted, but module remains active in a potentially non-functional state. AutoSelect mode requires a valid block selection to function properly, yet the module continues execution without validating this critical requirement.

Suggested change
HitResult hitResult = mc.crosshairTarget;
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
} else {
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");
}
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
autoSelectBlock = mc.world.getBlockState(pos).getBlock();
} else {
autoSelectBlock = null;
warning("No block is being targeted for auto-select mode.");
toggle();
}
Standards
  • Logic-Verification-Preconditions
  • Business-Rule-Validation
  • Algorithm-Correctness-State-Validation

Comment on lines +285 to +289
@Override
public void onDeactivate() {
if (listMode.get() == ListMode.AutoSelect) {
autoSelectBlock = null;
}
Copy link

Choose a reason for hiding this comment

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

Missing State Reset

The onDeactivate method only resets autoSelectBlock but doesn't call the parent class implementation. This could lead to incomplete state reset when module is deactivated.

Standards
  • Clean-Code-Method-Completeness
  • Design-Pattern-Template-Method

Comment on lines +410 to +412
case AutoSelect -> {
if (autoSelectBlock == null || !blockState.getBlock().equals(autoSelectBlock))
return;
Copy link

Choose a reason for hiding this comment

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

Unrestricted Block Breaking

AutoSelect mode allows breaking specific blocks without rate limiting. Malicious users could target valuable blocks for rapid destruction, potentially causing server-side performance issues or griefing.

Suggested change
case AutoSelect -> {
if (autoSelectBlock == null || !blockState.getBlock().equals(autoSelectBlock))
return;
if (autoSelectBlock == null || !blockState.getBlock().equals(autoSelectBlock))
return;
// Apply rate limiting for AutoSelect mode
if (timer < delay.get()) return;
Standards
  • CWE-284
  • OWASP-A01

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.

3 participants