feat: Added increment-block-statistics - #90
Open
awdrgyj8 wants to merge 6 commits into
Open
Conversation
MagicTeaMC
requested changes
Apr 4, 2026
MagicTeaMC
requested changes
Apr 4, 2026
MagicTeaMC
left a comment
Member
There was a problem hiding this comment.
Statistic might be double-counted if call-block-break-event is also true, any idea to prevent?
BTW, please allow me to edit this PR
| import org.milkteamc.autotreechop.Config; | ||
| import org.milkteamc.autotreechop.PlayerConfig; | ||
|
|
||
| import static org.bukkit.Statistic.MINE_BLOCK; |
Member
There was a problem hiding this comment.
import org.bukkit.Statistic, don't use static
| } | ||
|
|
||
| if (config.isIncrementBlockStatistics()) { | ||
| Material leafMaterial = leafBlock.getType(); |
Author
|
Of course. Thank you for reviewing my PR. |
Chopped blocks were always dropped on the ground with breakNaturally(), which leaves logs scattered around the top of a large tree where the player cannot reach them. Adds an opt-in auto pickup path: drops are read with block.getDrops(tool, player) before the block is cleared, so Fortune, Silk Touch and the tool type are respected exactly like a vanilla break. Both the log phase and the leaf phase (when leaf-removal-drop-items is on) are covered; the log the player originally broke is included since it is part of the BFS result and goes through the same path. Drops are accumulated during the batches and handed over once in the batch completion callback, next to the existing statistic flush and tool damage. That keeps inventory mutation out of the per-block loop and means at most one "inventory full" message per chop. Whatever does not fit is dropped at the player's feet. Gated behind enable-auto-pickup (default false, so existing servers are unaffected) and the new autotreechop.autopickup permission (default true), following the existing config-flag-and-permission pattern. Since setType(AIR) shows no break particles where breakNaturally() did, EffectUtils.showBlockBreakEffect() restores them under the existing visual-effect option. It emits particles only, so it does not double up on the playBreakSound option. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MjYARRStYz4VsBfGJuAHi
…types Two related leaf-removal bugs reported for jungle trees: 1. VINE was never in the default leaf-types list, so isLeafBlock() always rejected it — vines on jungle logs/leaves were never even considered for removal. Added VINE to config.yml's leaf-types. 2. Leaf capture/discovery was centered on the single block the player broke, with a fixed radius (leaf-removal-radius). Trunk discovery has no such radius limit (BFS up to max-tree-size), so on very tall trees — giant/mega jungle trees are commonly 20-30 blocks tall — the canopy near the top can sit well outside that fixed sphere while the whole trunk still gets chopped, leaving the topmost leaves and vines untouched. executeTreeChop now derives the leaf capture center from the vertical midpoint of the whole discovered trunk (treeBlocks), and grows the radius by half the trunk's vertical span so the capture sphere always reaches from the lowest to the highest log plus the configured margin. Short trees are unaffected (span ~0, same behavior as before). The grown radius is capped at MAX_LEAF_CAPTURE_RADIUS (32) since captureLeafRegion runs synchronously on the main/region thread — protects against a pathologically tall block stack turning into an enormous scan. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwwgSu7Yw29tb4XS8F3crn
…ollect-nup72g Claude/plugin tree auto collect nup72g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new boolean config option
increment-block-statistics(default: false) that callsplayer.incrementStatistic(MINE_BLOCK)for every block broken by ATC, including all chain-chopped logs and leaves removed by leaf removal. Disabled by default to preserve existing behavior.