Skip to content

Break mangrove roots in shift down mode if setting is enabled#831

Merged
Rakambda merged 1 commit intominecraft/1.21.4from
feature/1.21.4/mangrove-shift-down
Mar 26, 2025
Merged

Break mangrove roots in shift down mode if setting is enabled#831
Rakambda merged 1 commit intominecraft/1.21.4from
feature/1.21.4/mangrove-shift-down

Conversation

@Rakambda
Copy link
Copy Markdown
Member

No description provided.

@Rakambda Rakambda self-assigned this Mar 25, 2025
@Rakambda Rakambda requested a review from a team as a code owner March 25, 2025 08:09
@Rakambda Rakambda linked an issue Mar 25, 2025 that may be closed by this pull request
Copy link
Copy Markdown

@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.

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() to ITreeConfiguration to control whether mangrove roots are broken in shift-down mode.
  • Tree Structure: Added getMangroveRoots() to the Tree class to retrieve all mangrove root parts of a tree.
  • Breaking Logic: Modified ShiftDownTreeBreakingHandler to 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.
  • common/src/main/java/fr/rakambda/fallingtree/common/tree/Tree.java
    • Added imports for IBlockPos, ILevel, Getter, and RequiredArgsConstructor.
    • Moved imports to the top of the file.
    • Added getMangroveRoots() method to retrieve mangrove root parts.
  • common/src/main/java/fr/rakambda/fallingtree/common/tree/breaking/ShiftDownTreeBreakingHandler.java
    • Added imports for Collection, List, MANGROVE_ROOTS, and NETHER_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.
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

  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
Copy Markdown

@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

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 getWarts is renamed to getNetherWarts, 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-else block in ShiftDownTreeBreakingHandler.java could 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(){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

Suggested change
public Collection<TreePart> getNetherWarts(){
public Collection<TreePart> getNetherWarts(){

Comment on lines 41 to 47
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());
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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());
}
Suggested change
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());
}

@Rakambda Rakambda merged commit 0b79a3b into minecraft/1.21.4 Mar 26, 2025
@Rakambda Rakambda deleted the feature/1.21.4/mangrove-shift-down branch March 26, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mangrove Roots Aren't Disappearing

1 participant