第65批修复8:连锁采集策略修正
Auto Release / build (push) Successful in 2m47s

树木:以被破坏方块为中心,垂直上下搜索(树干天然上下连通,不需要水平辐射)
矿物:以被破坏方块为中心,水平9×9搜索(不管是否连在一起,卡墙里的也采到)

之前树木先扫树干再水平辐射是错的,会误采旁边树木。
改为纯垂直搜索,矿物保持纯水平9×9搜索。
This commit is contained in:
youpaishidifu
2026-11-01 11:27:04 +08:00
parent 1bdb52f34c
commit 3bbdf43062
+13 -18
View File
@@ -4039,7 +4039,7 @@ public class Main extends JavaPlugin
if (isOre && !isPickaxe) return; if (isOre && !isPickaxe) return;
if (isLog && !isAxe) return; if (isLog && !isAxe) return;
// 连锁采集:树木优先垂直,矿物水平辐射 // 连锁采集:树木垂直上下搜索,矿物水平9×9搜索
org.bukkit.Location center = centerBlock.getLocation(); org.bukkit.Location center = centerBlock.getLocation();
int range = 4; // 9×9 = 中心±4 int range = 4; // 9×9 = 中心±4
@@ -4050,34 +4050,29 @@ public class Main extends JavaPlugin
int cz = center.getBlockZ(); int cz = center.getBlockZ();
if (isLog) { if (isLog) {
// 树木:先垂直扫描树干,再从树顶水平辐射 // 树木:以被破坏方块为中心,垂直上下搜索整棵树干
// 1. 向上找同类型树干,直到找不到 // 树干天然上下连通,水平方向不需要辐射
List<org.bukkit.block.Block> trunkBlocks = new ArrayList<>(); // 向上搜索
for (int y = cy; y <= 255; y++) { for (int y = cy + 1; y <= 255; y++) {
org.bukkit.block.Block block = world.getBlockAt(cx, y, cz); org.bukkit.block.Block block = world.getBlockAt(cx, y, cz);
if (block.getType() == targetType && block.getType().isSolid()) { if (block.getType() == targetType && block.getType().isSolid()) {
trunkBlocks.add(block); sameTypeBlocks.add(block);
} else { } else {
break; // 树干结束 break; // 树干结束
} }
} }
// 2. 从每个树干位置水平 9×9 辐射 // 向下搜索
for (org.bukkit.block.Block trunk : trunkBlocks) { for (int y = cy - 1; y >= 0; y--) {
int tx = trunk.getX(); org.bukkit.block.Block block = world.getBlockAt(cx, y, cz);
int ty = trunk.getY();
int tz = trunk.getZ();
for (int x = -range; x <= range; x++) {
for (int z = -range; z <= range; z++) {
if (x == 0 && z == 0) continue; // 跳过树干本身(已收集)
org.bukkit.block.Block block = world.getBlockAt(tx + x, ty, tz + z);
if (block.getType() == targetType && block.getType().isSolid()) { if (block.getType() == targetType && block.getType().isSolid()) {
sameTypeBlocks.add(block); sameTypeBlocks.add(block);
} } else {
} break; // 树干结束
} }
} }
} else { } else {
// 矿物:直接水平 9×9 辐射 // 矿物:以被破坏方块为中心,水平9×9搜索
// 不管是否连在一起,卡墙里的也采到
for (int x = -range; x <= range; x++) { for (int x = -range; x <= range; x++) {
for (int z = -range; z <= range; z++) { for (int z = -range; z <= range; z++) {
if (x == 0 && z == 0) continue; // 跳过中心方块 if (x == 0 && z == 0) continue; // 跳过中心方块