Relax tree detection and keep the old neighbour check behind tree-strict-mode.
Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -34,6 +34,7 @@ final class TreeIndex {
34
34
private final int maxLogs;
35
35
private final int maxLeafVisits;
36
36
private final int scanAboveGround;
37
private final boolean strictMode;
37
38
38
39
private final Map<ChunkKey, ChunkScan> chunks = new HashMap<>();
39
40
private final Map<UUID, DetectedTree> trees = new HashMap<>();
@@ -47,6 +48,7 @@ final class TreeIndex {
47
48
this.maxLogs = Math.max(8, plugin.getConfig().getInt("tree-max-logs", 64));
48
49
this.maxLeafVisits = Math.max(32, plugin.getConfig().getInt("tree-max-leaf-visits", 128));
49
50
this.scanAboveGround = Math.max(8, plugin.getConfig().getInt("tree-scan-above-ground", 40));
51
this.strictMode = plugin.getConfig().getBoolean("tree-strict-mode", false);
50
52
}
51
53
52
54
void tick() {
@@ -327,10 +329,12 @@ final class TreeIndex {
327
329
for (BlockRef log : logs) {
328
330
Block block = log.blockIfLoaded();
329
331
if (block == null || block.getType() != logType) return null;
330
for (BlockFace face : HORIZONTAL) {
331
Block neighbour = block.getRelative(face);
332
if (!registry.isAllowedHorizontal(neighbour.getType(), logType, allowedLeaves, neighbour)) {
333
return null;
332
if (strictMode) {
333
for (BlockFace face : HORIZONTAL) {
334
Block neighbour = block.getRelative(face);
335
if (!registry.isAllowedHorizontal(neighbour.getType(), logType, allowedLeaves, neighbour)) {
336
return null;
337
}
334
338
}
335
339
}
336
340
if (log.y() == highestY) {
@@ -34,6 +34,7 @@ final class TreeIndex {34
private final int maxLogs;34
private final int maxLogs;35
private final int maxLeafVisits;35
private final int maxLeafVisits;36
private final int scanAboveGround;36
private final int scanAboveGround;37
private final boolean strictMode;37
38
38
private final Map<ChunkKey, ChunkScan> chunks = new HashMap<>();39
private final Map<ChunkKey, ChunkScan> chunks = new HashMap<>();39
private final Map<UUID, DetectedTree> trees = new HashMap<>();40
private final Map<UUID, DetectedTree> trees = new HashMap<>();@@ -47,6 +48,7 @@ final class TreeIndex {47
this.maxLogs = Math.max(8, plugin.getConfig().getInt("tree-max-logs", 64));48
this.maxLogs = Math.max(8, plugin.getConfig().getInt("tree-max-logs", 64));48
this.maxLeafVisits = Math.max(32, plugin.getConfig().getInt("tree-max-leaf-visits", 128));49
this.maxLeafVisits = Math.max(32, plugin.getConfig().getInt("tree-max-leaf-visits", 128));49
this.scanAboveGround = Math.max(8, plugin.getConfig().getInt("tree-scan-above-ground", 40));50
this.scanAboveGround = Math.max(8, plugin.getConfig().getInt("tree-scan-above-ground", 40));51
this.strictMode = plugin.getConfig().getBoolean("tree-strict-mode", false);50
}52
}51
53
52
void tick() {54
void tick() {@@ -327,10 +329,12 @@ final class TreeIndex {327
for (BlockRef log : logs) {329
for (BlockRef log : logs) {328
Block block = log.blockIfLoaded();330
Block block = log.blockIfLoaded();329
if (block == null || block.getType() != logType) return null;331
if (block == null || block.getType() != logType) return null;330
for (BlockFace face : HORIZONTAL) {332
if (strictMode) {331
Block neighbour = block.getRelative(face);333
for (BlockFace face : HORIZONTAL) {332
if (!registry.isAllowedHorizontal(neighbour.getType(), logType, allowedLeaves, neighbour)) {334
Block neighbour = block.getRelative(face);333
return null;335
if (!registry.isAllowedHorizontal(neighbour.getType(), logType, allowedLeaves, neighbour)) {336
return null;337
}334
}338
}335
}339
}336
if (log.y() == highestY) {340
if (log.y() == highestY) {@@ -70,3 +70,9 @@ tree-max-leaf-visits: 128
70
70
# How far above the no-leaves heightmap a column is checked for a trunk.
71
71
# Columns are never scanned downward into stone/ore.
72
72
tree-scan-above-ground: 40
73
74
# When true, every log must be horizontally surrounded only by air, same-type
75
# logs, matching natural leaves, or known natural clutter. Default is false:
76
# a recognised trunk on valid soil with matching non-persistent leaves on top
77
# is enough, regardless of neighbouring blocks.
78
tree-strict-mode: false
@@ -70,3 +70,9 @@ tree-max-leaf-visits: 12870
# How far above the no-leaves heightmap a column is checked for a trunk.70
# How far above the no-leaves heightmap a column is checked for a trunk.71
# Columns are never scanned downward into stone/ore.71
# Columns are never scanned downward into stone/ore.72
tree-scan-above-ground: 4072
tree-scan-above-ground: 4073
74
# When true, every log must be horizontally surrounded only by air, same-type75
# logs, matching natural leaves, or known natural clutter. Default is false:76
# a recognised trunk on valid soil with matching non-persistent leaves on top77
# is enough, regardless of neighbouring blocks.78
tree-strict-mode: false