-
Notifications
You must be signed in to change notification settings - Fork 0
Clone feature/nuker auto select #6
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughAdds 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 theonDeactivate
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
-
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. ↩
Nuker Module Auto-Select ModeTL;DR: Added an "AutoSelect" mode to the Nuker module that allows targeting specific blocks by looking at them. Refacto PR SummaryEnhanced the Nuker module with a new AutoSelect mode that dynamically targets blocks based on player's crosshair. Change HighlightsClick to expand
Sequence DiagramsequenceDiagram
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
Testing GuideClick to expand
|
/refacto-test |
Refacto is reviewing this PR. Please wait for the review comments to be posted. |
There was a problem hiding this 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.
autoSelectBlock = null; | ||
warning("No block is being targeted for auto-select mode."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
Code Review: Nuker AutoSelect Implementation👍 Well Done
📌 Files Processed
📝 Additional Comments
|
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."); | ||
} | ||
} |
There was a problem hiding this comment.
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
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."); | ||
} | ||
} |
There was a problem hiding this comment.
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
@Override | ||
public void onDeactivate() { | ||
if (listMode.get() == ListMode.AutoSelect) { | ||
autoSelectBlock = null; | ||
} | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this 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.
📒 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.
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."); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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.
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.
/refacto-test |
Refacto is reviewing this PR. Please wait for the review comments to be posted. |
Code Review: Nuker AutoSelect Implementation👍 Well Done
📌 Files Processed
📝 Additional Comments
|
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) { | ||
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos(); | ||
autoSelectBlock = mc.world.getBlockState(pos).getBlock(); |
There was a problem hiding this comment.
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.
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
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."); | ||
} |
There was a problem hiding this comment.
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.
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
@Override | ||
public void onDeactivate() { | ||
if (listMode.get() == ListMode.AutoSelect) { | ||
autoSelectBlock = null; | ||
} |
There was a problem hiding this comment.
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
case AutoSelect -> { | ||
if (autoSelectBlock == null || !blockState.getBlock().equals(autoSelectBlock)) | ||
return; |
There was a problem hiding this comment.
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.
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
Type of change
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:
Summary by CodeRabbit