use of com.ferreusveritas.dynamictrees.api.treedata.ITreePart in project DynamicTrees by DynamicTreesTeam.
the class TreeHelper method findRootNode.
/**
* Find the root node of a tree.
*
* @param world The world
* @param pos The position being analyzed
* @return The position of the root node of the tree or BlockPos.ORIGIN if nothing was found.
*/
public static BlockPos findRootNode(World world, BlockPos pos) {
pos = dereferenceTrunkShell(world, pos);
IBlockState state = world.getBlockState(pos);
ITreePart treePart = TreeHelper.getTreePart(state);
switch(treePart.getTreePartType()) {
case BRANCH:
// Analyze entire tree network to find root node
MapSignal signal = treePart.analyse(state, world, pos, null, new MapSignal());
if (signal.found) {
return signal.root;
}
break;
case ROOT:
return pos;
default:
return BlockPos.ORIGIN;
}
return BlockPos.ORIGIN;
}
Aggregations