Skip to content

Make flowers and DoublePlants break like vanilla#2247

Merged
PetteriM1 merged 3 commits intoCloudburstMC:masterfrom
kaniteru:master
Nov 20, 2025
Merged

Make flowers and DoublePlants break like vanilla#2247
PetteriM1 merged 3 commits intoCloudburstMC:masterfrom
kaniteru:master

Conversation

@kaniteru
Copy link
Contributor

@kaniteru kaniteru commented Nov 15, 2025

  • Fix issue where items didn't drop when breaking the top part of tall grass
  • Add particle effects were only played for the top/bottom parts when breaking tall grass

In vanilla, shears should consume durability when breaking grass and flowers; otherwise, they should not.

So,

  • Overridden getToolType() and breakWhenPushed() in BlockFlower and BlockDoublePlant.
  • Make durability not decrease when breaking grass and flowers with tools other than shears

In vanilla, shears should consume durability.
- Fix issue where items didn't drop when breaking the top part of tall grass
- Fix issue where particle effects were only played for the top/bottom parts when breaking tall grass
- Overridden getToolType() and breakWhenPushed()
Copy link
Contributor

@xRookieFight xRookieFight left a comment

Choose a reason for hiding this comment

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

This empty if statement isn't well

@kaniteru
Copy link
Contributor Author

kaniteru commented Nov 15, 2025

@xRookieFight
Yes, I think so too. However, I'm not sure how to incorporate this condition while maintaining the existing coding style.

This is the optimal code I can think of is this:

@Override
public boolean useOn(Block block) {
    if (this.noDamageOnBreak() || this.isUnbreakable() || this.isDurable()) {
        return true;
    }
    
    if (block.getToolType() == ItemTool.TYPE_PICKAXE && this.isPickaxe() ||
            block.getToolType() == ItemTool.TYPE_SHOVEL && this.isShovel() ||
            block.getToolType() == ItemTool.TYPE_AXE && this.isAxe() ||
            block.getToolType() == ItemTool.TYPE_HOE && this.isHoe() ||
            block.getToolType() == ItemTool.TYPE_SWORD && this.isSword() ||
            block.getToolType() == ItemTool.TYPE_SHEARS && this.isShears()
            ) {
        this.meta++;
        return true;
    }
    
    if (this.isSword() && block.getHardness() > 0) {
        this.meta += 2;
        return true;
    }
    
    if (this.isHoe() && ((block.getId() == GRASS || block.getId() == DIRT))) {
        this.meta++;
        return true;
    }
    
    if (block.getId() == TALL_GRASS || block.getId() == FLOWER || block.getId() == DOUBLE_PLANT) {
        return true;
    }
    
    this.meta++;
    return true;
}

Or

int damage = 0;

...

this.meta += damage;
return true;

@kaniteru
Copy link
Contributor Author

ahh, I didn't mean to rush you, sorry :/

@xRookieFight
Copy link
Contributor

No worries 😄, the first one is more optimized for me. You can commit that

- In vanilla, blocks of grass and flowers do not affect the durability of tools other than shears

I have no idea how to add new code while maintaining the existing code style
@kaniteru
Copy link
Contributor Author

kaniteru commented Nov 15, 2025

I hope I performed the push correctly

Copy link
Contributor

@xRookieFight xRookieFight left a comment

Choose a reason for hiding this comment

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

Looks fine to me

if (block.getId() == GRASS || block.getId() == DIRT) {
this.meta++;
}
} else if (block.getId() == TALL_GRASS || block.getId() == FLOWER || block.getId() == DOUBLE_PLANT) {

This comment was marked as resolved.

@PetteriM1 PetteriM1 merged commit e7021d0 into CloudburstMC:master Nov 20, 2025
1 check passed
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