clear unnecessary diffs
This commit is contained in:
parent
ad37c5d949
commit
918c8082b1
1 changed files with 10 additions and 12 deletions
|
@ -56,29 +56,27 @@ public class TreeCutter {
|
||||||
/**
|
/**
|
||||||
* Finds a tree at the given pos. Block at the position should be air
|
* Finds a tree at the given pos. Block at the position should be air
|
||||||
*
|
*
|
||||||
* @param world
|
* @param reader
|
||||||
* @param pos
|
* @param pos
|
||||||
* @return null if not found or not fully cut
|
* @return null if not found or not fully cut
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static AbstractBlockBreakQueue findTree(@Nullable IBlockReader world, BlockPos pos) {
|
public static Tree findTree(@Nullable IBlockReader reader, BlockPos pos) {
|
||||||
if (world == null)
|
if (reader == null)
|
||||||
return NO_TREE;
|
return NO_TREE;
|
||||||
|
|
||||||
List<BlockPos> logs = new ArrayList<>();
|
List<BlockPos> logs = new ArrayList<>();
|
||||||
logs.add(pos);
|
|
||||||
|
|
||||||
List<BlockPos> leaves = new ArrayList<>();
|
List<BlockPos> leaves = new ArrayList<>();
|
||||||
Set<BlockPos> visited = new HashSet<>();
|
Set<BlockPos> visited = new HashSet<>();
|
||||||
List<BlockPos> frontier = new LinkedList<>();
|
List<BlockPos> frontier = new LinkedList<>();
|
||||||
|
|
||||||
// Bamboo, Sugar Cane, Cactus
|
// Bamboo, Sugar Cane, Cactus
|
||||||
BlockState stateAbove = world.getBlockState(pos.up());
|
BlockState stateAbove = reader.getBlockState(pos.up());
|
||||||
if (isVerticalPlant(stateAbove)) {
|
if (isVerticalPlant(stateAbove)) {
|
||||||
logs.add(pos.up());
|
logs.add(pos.up());
|
||||||
for (int i = 1; i < 256; i++) {
|
for (int i = 1; i < 256; i++) {
|
||||||
BlockPos current = pos.up(i);
|
BlockPos current = pos.up(i);
|
||||||
if (!isVerticalPlant(world.getBlockState(current)))
|
if (!isVerticalPlant(reader.getBlockState(current)))
|
||||||
break;
|
break;
|
||||||
logs.add(current);
|
logs.add(current);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +95,7 @@ public class TreeCutter {
|
||||||
BlockPos offset = current.offset(direction);
|
BlockPos offset = current.offset(direction);
|
||||||
if (visited.contains(offset))
|
if (visited.contains(offset))
|
||||||
continue;
|
continue;
|
||||||
if (!isChorus(world.getBlockState(offset)))
|
if (!isChorus(reader.getBlockState(offset)))
|
||||||
continue;
|
continue;
|
||||||
frontier.add(offset);
|
frontier.add(offset);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +105,7 @@ public class TreeCutter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regular Tree
|
// Regular Tree
|
||||||
if (!validateCut(world, pos))
|
if (!validateCut(reader, pos))
|
||||||
return NO_TREE;
|
return NO_TREE;
|
||||||
|
|
||||||
visited.add(pos);
|
visited.add(pos);
|
||||||
|
@ -121,7 +119,7 @@ public class TreeCutter {
|
||||||
continue;
|
continue;
|
||||||
visited.add(currentPos);
|
visited.add(currentPos);
|
||||||
|
|
||||||
if (!isLog(world.getBlockState(currentPos)))
|
if (!isLog(reader.getBlockState(currentPos)))
|
||||||
continue;
|
continue;
|
||||||
logs.add(currentPos);
|
logs.add(currentPos);
|
||||||
addNeighbours(currentPos, frontier, visited);
|
addNeighbours(currentPos, frontier, visited);
|
||||||
|
@ -137,7 +135,7 @@ public class TreeCutter {
|
||||||
continue;
|
continue;
|
||||||
visited.add(currentPos);
|
visited.add(currentPos);
|
||||||
|
|
||||||
BlockState blockState = world.getBlockState(currentPos);
|
BlockState blockState = reader.getBlockState(currentPos);
|
||||||
boolean isLog = isLog(blockState);
|
boolean isLog = isLog(blockState);
|
||||||
boolean isLeaf = isLeaf(blockState);
|
boolean isLeaf = isLeaf(blockState);
|
||||||
boolean isGenericLeaf = isLeaf || isNonDecayingLeaf(blockState);
|
boolean isGenericLeaf = isLeaf || isNonDecayingLeaf(blockState);
|
||||||
|
@ -152,7 +150,7 @@ public class TreeCutter {
|
||||||
BlockPos offset = currentPos.offset(direction);
|
BlockPos offset = currentPos.offset(direction);
|
||||||
if (visited.contains(offset))
|
if (visited.contains(offset))
|
||||||
continue;
|
continue;
|
||||||
BlockState state = world.getBlockState(offset);
|
BlockState state = reader.getBlockState(offset);
|
||||||
BlockPos subtract = offset.subtract(pos);
|
BlockPos subtract = offset.subtract(pos);
|
||||||
int horizontalDistance = Math.max(Math.abs(subtract.getX()), Math.abs(subtract.getZ()));
|
int horizontalDistance = Math.max(Math.abs(subtract.getX()), Math.abs(subtract.getZ()));
|
||||||
if (isLeaf(state) && state.get(LeavesBlock.DISTANCE) > distance
|
if (isLeaf(state) && state.get(LeavesBlock.DISTANCE) > distance
|
||||||
|
|
Loading…
Reference in a new issue