Skip to content

feat: Added increment-block-statistics - #90

Open
awdrgyj8 wants to merge 6 commits into
milkteamc:masterfrom
OriginCraft-Team:master
Open

feat: Added increment-block-statistics#90
awdrgyj8 wants to merge 6 commits into
milkteamc:masterfrom
OriginCraft-Team:master

Conversation

@awdrgyj8

@awdrgyj8 awdrgyj8 commented Apr 4, 2026

Copy link
Copy Markdown

Add a new boolean config option increment-block-statistics (default: false) that calls player.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.

Comment thread src/main/java/org/milkteamc/autotreechop/utils/TreeChopUtils.java Outdated
Comment thread src/main/java/org/milkteamc/autotreechop/utils/TreeChopUtils.java Outdated
Comment thread src/main/java/org/milkteamc/autotreechop/utils/TreeChopUtils.java Outdated
Comment thread src/main/resources/config.yml Outdated

@awdrgyj8 awdrgyj8 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

All been resolved.

@MagicTeaMC MagicTeaMC left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

import org.bukkit.Statistic, don't use static

}

if (config.isIncrementBlockStatistics()) {
Material leafMaterial = leafBlock.getType();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this will always return AIR

@awdrgyj8

awdrgyj8 commented Apr 5, 2026

Copy link
Copy Markdown
Author

Of course. Thank you for reviewing my PR.

@MagicTeaMC MagicTeaMC added enhancement New feature or request java Pull requests that update java code labels Jun 11, 2026
claude and others added 3 commits August 26, 2026 07:16
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request java Pull requests that update java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants