mirror of
https://github.com/songoda/UltimateTimber.git
synced 2024-09-27 13:22:39 +02:00
Fix tree detection with destroyleaves disabled.
This commit is contained in:
parent
bcde04159d
commit
9903170d00
@ -2,22 +2,13 @@ package com.songoda.ultimatetimber.manager;
|
||||
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.adapter.IBlockData;
|
||||
import com.songoda.ultimatetimber.tree.DetectedTree;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlockSet;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlockType;
|
||||
import com.songoda.ultimatetimber.tree.TreeDefinition;
|
||||
import com.songoda.ultimatetimber.tree.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class TreeDetectionManager extends Manager {
|
||||
|
||||
@ -113,23 +104,20 @@ public class TreeDetectionManager extends Manager {
|
||||
|
||||
// Detect leaves off the trunk/branches
|
||||
Set<ITreeBlock<Block>> branchBlocks = new HashSet<>(detectedTreeBlocks.getLogBlocks());
|
||||
for (ITreeBlock<Block> branchBlock : branchBlocks) {
|
||||
for (ITreeBlock<Block> branchBlock : branchBlocks)
|
||||
this.recursiveLeafSearch(possibleTreeDefinitions, detectedTreeBlocks, branchBlock.getBlock(), new HashSet<>());
|
||||
|
||||
// Check if we can stop checking early if we don't care about the leaves
|
||||
if (!this.destroyLeaves && detectedTreeBlocks.getLeafBlocks().size() < this.numLeavesRequiredForTree) {
|
||||
detectedTreeBlocks.removeAll(TreeBlockType.LEAF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Use the first tree definition in the set
|
||||
TreeDefinition actualTreeDefinition = possibleTreeDefinitions.iterator().next();
|
||||
|
||||
// Trees need at least a certain number of leaves
|
||||
if (this.destroyLeaves && detectedTreeBlocks.getLeafBlocks().size() < this.numLeavesRequiredForTree)
|
||||
if (detectedTreeBlocks.getLeafBlocks().size() < this.numLeavesRequiredForTree)
|
||||
return null;
|
||||
|
||||
// Remove leaves if we don't care about the leaves
|
||||
if (!this.destroyLeaves)
|
||||
detectedTreeBlocks.removeAll(TreeBlockType.LEAF);
|
||||
|
||||
// Check that the tree isn't on the ground if enabled
|
||||
if (this.entireTreeBase) {
|
||||
Set<Block> groundBlocks = new HashSet<>();
|
||||
@ -185,7 +173,6 @@ public class TreeDetectionManager extends Manager {
|
||||
* Recursively searches for leaves that are next to this tree
|
||||
*
|
||||
* @param treeDefinitions The possible tree definitions
|
||||
*
|
||||
* @param treeBlocks The detected tree blocks
|
||||
* @param block The next block to check for a leaf
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user