From 918c8082b1a279c1caafb6cd9c5541d9ef6bcc3c Mon Sep 17 00:00:00 2001 From: grimmauld Date: Thu, 20 May 2021 08:42:29 +0200 Subject: [PATCH] clear unnecessary diffs --- .../create/foundation/utility/TreeCutter.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java index e92c788c3..598ec71cd 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java +++ b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java @@ -56,29 +56,27 @@ public class TreeCutter { /** * Finds a tree at the given pos. Block at the position should be air * - * @param world + * @param reader * @param pos * @return null if not found or not fully cut */ @Nonnull - public static AbstractBlockBreakQueue findTree(@Nullable IBlockReader world, BlockPos pos) { - if (world == null) + public static Tree findTree(@Nullable IBlockReader reader, BlockPos pos) { + if (reader == null) return NO_TREE; List logs = new ArrayList<>(); - logs.add(pos); - List leaves = new ArrayList<>(); Set visited = new HashSet<>(); List frontier = new LinkedList<>(); // Bamboo, Sugar Cane, Cactus - BlockState stateAbove = world.getBlockState(pos.up()); + BlockState stateAbove = reader.getBlockState(pos.up()); if (isVerticalPlant(stateAbove)) { logs.add(pos.up()); for (int i = 1; i < 256; i++) { BlockPos current = pos.up(i); - if (!isVerticalPlant(world.getBlockState(current))) + if (!isVerticalPlant(reader.getBlockState(current))) break; logs.add(current); } @@ -97,7 +95,7 @@ public class TreeCutter { BlockPos offset = current.offset(direction); if (visited.contains(offset)) continue; - if (!isChorus(world.getBlockState(offset))) + if (!isChorus(reader.getBlockState(offset))) continue; frontier.add(offset); } @@ -107,7 +105,7 @@ public class TreeCutter { } // Regular Tree - if (!validateCut(world, pos)) + if (!validateCut(reader, pos)) return NO_TREE; visited.add(pos); @@ -121,7 +119,7 @@ public class TreeCutter { continue; visited.add(currentPos); - if (!isLog(world.getBlockState(currentPos))) + if (!isLog(reader.getBlockState(currentPos))) continue; logs.add(currentPos); addNeighbours(currentPos, frontier, visited); @@ -137,7 +135,7 @@ public class TreeCutter { continue; visited.add(currentPos); - BlockState blockState = world.getBlockState(currentPos); + BlockState blockState = reader.getBlockState(currentPos); boolean isLog = isLog(blockState); boolean isLeaf = isLeaf(blockState); boolean isGenericLeaf = isLeaf || isNonDecayingLeaf(blockState); @@ -152,7 +150,7 @@ public class TreeCutter { BlockPos offset = currentPos.offset(direction); if (visited.contains(offset)) continue; - BlockState state = world.getBlockState(offset); + BlockState state = reader.getBlockState(offset); BlockPos subtract = offset.subtract(pos); int horizontalDistance = Math.max(Math.abs(subtract.getX()), Math.abs(subtract.getZ())); if (isLeaf(state) && state.get(LeavesBlock.DISTANCE) > distance