Tree detection entire tree base check

This commit is contained in:
Esophose 2019-03-28 16:19:52 -06:00
parent e3bbc814f3
commit 94ffdcc5f5
1 changed files with 20 additions and 2 deletions

View File

@ -108,9 +108,27 @@ public class TreeDetectionManager extends Manager {
if (detectedTreeBlocks.getLeafBlocks().size() < this.numLeavesRequiredForTree)
return null;
// TODO: Soil detection
// Check that the tree isn't on the ground if enabled
if (this.entireTreeBase) {
// TODO: Yadda yadda
Set<Block> groundBlocks = new HashSet<>();
for (ITreeBlock<Block> treeBlock : detectedTreeBlocks.getLogBlocks())
if (treeBlock.getLocation().getBlockY() == initialBlock.getLocation().getBlockY())
groundBlocks.add(treeBlock.getBlock());
for (Block block : groundBlocks) {
Block blockBelow = block.getRelative(BlockFace.DOWN);
boolean blockBelowIsLog = this.isValidLogType(possibleTreeDefinitions, blockBelow);
boolean blockBelowIsSoil = false;
for (IBlockData blockData : actualTreeDefinition.getPlantableSoilBlockData()) {
if (blockData.isSimilar(blockBelow)) {
blockBelowIsSoil = true;
break;
}
}
if (!blockBelowIsLog && blockBelowIsSoil)
return null;
}
}
// Delete the starting block if applicable