Break mangrove roots in shift down mode if setting is enabled#831
Break mangrove roots in shift down mode if setting is enabled#831Rakambda merged 1 commit intominecraft/1.21.4from
Conversation
There was a problem hiding this comment.
Hello @Rakambda, 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!
Summary of Changes
This pull request introduces a new feature that allows mangrove roots to be broken in shift-down mode if a corresponding setting is enabled. This change involves modifying the configuration interface, adding a method to retrieve mangrove roots from a tree, and updating the shift-down tree breaking handler to include mangrove roots in the breaking logic.
Highlights
- Configuration: Added
isBreakMangroveRoots()toITreeConfigurationto control whether mangrove roots are broken in shift-down mode. - Tree Structure: Added
getMangroveRoots()to theTreeclass to retrieve all mangrove root parts of a tree. - Breaking Logic: Modified
ShiftDownTreeBreakingHandlerto break mangrove roots if the configuration setting is enabled and the player is in shift-down mode.
Changelog
- common/src/main/java/fr/rakambda/fallingtree/common/config/ITreeConfiguration.java
- Added
boolean isBreakMangroveRoots();method to the interface.
- Added
- common/src/main/java/fr/rakambda/fallingtree/common/tree/Tree.java
- Added imports for
IBlockPos,ILevel,Getter, andRequiredArgsConstructor. - Moved imports to the top of the file.
- Added
getMangroveRoots()method to retrieve mangrove root parts.
- Added imports for
- common/src/main/java/fr/rakambda/fallingtree/common/tree/breaking/ShiftDownTreeBreakingHandler.java
- Added imports for
Collection,List,MANGROVE_ROOTS, andNETHER_WART. - Moved imports to the top of the file.
- Modified
breakTree()method to include mangrove roots in the breaking logic if the corresponding configuration is enabled.
- Added imports for
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 is currently in preview and 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 to provide feedback.
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.
Trivia time!
What is the primary function of mangrove roots in their natural environment?
Click here for the answer
Mangrove roots primarily function to stabilize the shoreline, prevent erosion, and provide habitat for various marine species.
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. ↩
There was a problem hiding this comment.
Code Review
The pull request introduces the functionality to break mangrove roots when shift-down mode is enabled, based on a configuration setting. This enhances the mod's tree-felling capabilities. The changes are relatively straightforward, but there are a few areas that could be improved for clarity and maintainability.
Summary of Findings
- Inconsistent Naming: The method name
getWartsis renamed togetNetherWarts, which is good for clarity. However, it's important to ensure consistency across the codebase. Consider if other methods might benefit from similar clarification. - Redundant Imports: The import statements were moved around in
ShiftDownTreeBreakingHandler.java. While this doesn't affect functionality, it's generally better to keep imports grouped logically (e.g., java standard library imports together, then external library imports, then project-specific imports) for readability. - Conditional Logic Clarity: The nested
if-else if-elseblock inShiftDownTreeBreakingHandler.javacould be slightly more readable by extracting the conditions into well-named variables.
Merge Readiness
The pull request is almost ready for merging. Addressing the comments regarding naming consistency and conditional logic clarity would improve the code quality. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging. I recommend that the pull request not be merged until the medium severity issues are addressed.
|
|
||
| @NotNull | ||
| public Collection<TreePart> getWarts(){ | ||
| public Collection<TreePart> getNetherWarts(){ |
There was a problem hiding this comment.
Consider renaming this to getNetherWarts for consistency with the TreePartType enum and to improve clarity. It's good that you renamed it here, but consider if the old name exists anywhere else in the codebase.
| public Collection<TreePart> getNetherWarts(){ | |
| public Collection<TreePart> getNetherWarts(){ |
| var level = tree.getLevel(); | ||
| if(treePart.treePartType() == NETHER_WART && mod.getConfiguration().getTrees().isBreakNetherTreeWarts()){ | ||
| return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getWarts()); | ||
| return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getNetherWarts()); | ||
| } | ||
| else if(treePart.treePartType() == MANGROVE_ROOTS && mod.getConfiguration().getTrees().isBreakMangroveRoots()){ | ||
| return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getMangroveRoots()); | ||
| } |
There was a problem hiding this comment.
For improved readability, consider extracting the conditions into well-named variables. This can make the logic easier to follow at a glance.
For example:
boolean isNetherWart = treePart.treePartType() == NETHER_WART && mod.getConfiguration().getTrees().isBreakNetherTreeWarts();
boolean isMangroveRoot = treePart.treePartType() == MANGROVE_ROOTS && mod.getConfiguration().getTrees().isBreakMangroveRoots();
if (isNetherWart) {
return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getNetherWarts());
} else if (isMangroveRoot) {
return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getMangroveRoots());
} else {
return breakElements(isCancellable, tree, level, player, tool, treePartLog, List.of());
}| var level = tree.getLevel(); | |
| if(treePart.treePartType() == NETHER_WART && mod.getConfiguration().getTrees().isBreakNetherTreeWarts()){ | |
| return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getWarts()); | |
| return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getNetherWarts()); | |
| } | |
| else if(treePart.treePartType() == MANGROVE_ROOTS && mod.getConfiguration().getTrees().isBreakMangroveRoots()){ | |
| return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getMangroveRoots()); | |
| } | |
| boolean isNetherWart = treePart.treePartType() == NETHER_WART && mod.getConfiguration().getTrees().isBreakNetherTreeWarts(); | |
| boolean isMangroveRoot = treePart.treePartType() == MANGROVE_ROOTS && mod.getConfiguration().getTrees().isBreakMangroveRoots(); | |
| if (isNetherWart) { | |
| return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getNetherWarts()); | |
| } else if (isMangroveRoot) { | |
| return breakElements(isCancellable, tree, level, player, tool, treePartLog, tree.getMangroveRoots()); | |
| } else { | |
| return breakElements(isCancellable, tree, level, player, tool, treePartLog, List.of()); | |
| } |
No description provided.