diff --git a/src/main/java/com/simibubi/create/content/kinetics/saw/SawBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/saw/SawBlockEntity.java index 1f78e2ae6..471bd8092 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/saw/SawBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/saw/SawBlockEntity.java @@ -259,7 +259,7 @@ public class SawBlockEntity extends BlockBreakingKineticBlockEntity { super.invalidate(); invProvider.invalidate(); } - + @Override public void destroy() { super.destroy(); @@ -351,8 +351,8 @@ public class SawBlockEntity extends BlockBreakingKineticBlockEntity { ItemHelper.addToList(stack, list); } } - - for (int slot = 0; slot < list.size() && slot + 1 < inventory.getSlots(); slot++) + + for (int slot = 0; slot < list.size() && slot + 1 < inventory.getSlots(); slot++) inventory.setStackInSlot(slot + 1, list.get(slot)); award(AllAdvancements.SAW_PROCESSING); @@ -461,7 +461,7 @@ public class SawBlockEntity extends BlockBreakingKineticBlockEntity { } super.onBlockBroken(stateToBreak); - TreeCutter.findTree(level, breakingPos) + TreeCutter.findTree(level, breakingPos, stateToBreak) .destroyBlocks(level, null, this::dropItemFromCutTree); } diff --git a/src/main/java/com/simibubi/create/content/kinetics/saw/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/kinetics/saw/SawMovementBehaviour.java index 77dee7634..0b2e14a3d 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/saw/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/kinetics/saw/SawMovementBehaviour.java @@ -72,7 +72,7 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { return; } - TreeCutter.findTree(context.world, pos) + TreeCutter.findTree(context.world, pos, brokenState) .destroyBlocks(context.world, null, (stack, dropPos) -> dropItemFromCutTree(context, stack, dropPos)); } 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 9cfe0d88f..4999f5a9f 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java +++ b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java @@ -55,15 +55,20 @@ public class TreeCutter { return Optional.empty(); } + @Deprecated(forRemoval = true) + public static Tree findTree(@Nullable BlockGetter reader, BlockPos pos) { + return findTree(reader, pos, Blocks.AIR.defaultBlockState()); + } + /** * Finds a tree at the given pos. Block at the position should be air * - * @param reader - * @param pos - * @return null if not found or not fully cut + * @param reader the level that will be searched for a tree + * @param pos position that the saw cut at + * @param brokenState block state what was broken by the saw */ @Nonnull - public static Tree findTree(@Nullable BlockGetter reader, BlockPos pos) { + public static Tree findTree(@Nullable BlockGetter reader, BlockPos pos, BlockState brokenState) { if (reader == null) return NO_TREE; @@ -72,11 +77,14 @@ public class TreeCutter { Set visited = new HashSet<>(); List frontier = new LinkedList<>(); - // Bamboo, Sugar Cane, Cactus BlockState stateAbove = reader.getBlockState(pos.above()); - if (isVerticalPlant(stateAbove)) { + // Bamboo, Sugar Cane, Cactus + if (isVerticalPlant(brokenState)) { + if (!isVerticalPlant(stateAbove)) + return NO_TREE; + logs.add(pos.above()); - for (int i = 1; i < 256; i++) { + for (int i = 1; i < reader.getHeight(); i++) { BlockPos current = pos.above(i); if (!isVerticalPlant(reader.getBlockState(current))) break; @@ -87,7 +95,10 @@ public class TreeCutter { } // Chorus - if (isChorus(stateAbove)) { + if (isChorus(brokenState)) { + if (!isChorus(stateAbove)) + return NO_TREE; + frontier.add(pos.above()); while (!frontier.isEmpty()) { BlockPos current = frontier.remove(0);