From efb864f413788e59c8b4d04add9b3aea209e66d8 Mon Sep 17 00:00:00 2001 From: Aleksi Lassila Date: Tue, 29 Oct 2024 21:19:01 +0200 Subject: [PATCH] Merge pull request #188 from bruned12/printer-1.20.1-3.2.1 Fix cant place slab (cherry picked from commit 2357b374d3223f3132e3f710279dc5158ff8a926) --- .../printer/guides/placement/SlabGuide.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/aleksilassila/litematica/printer/guides/placement/SlabGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/SlabGuide.java index ff9a03f68..8a08efbb4 100644 --- a/src/main/java/me/aleksilassila/litematica/printer/guides/placement/SlabGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/SlabGuide.java @@ -7,6 +7,7 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -17,10 +18,35 @@ public SlabGuide(SchematicBlockState state) { @Override protected List getPossibleSides() { - return Arrays.stream(Direction.values()) - .filter(d -> d != (getRequiredHalf(state).getOpposite()) && - getProperty(state.offset(d).currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) == SlabType.DOUBLE) - .toList(); + List resultList = new ArrayList<>(); + SlabType targetSlabType = getProperty(state.targetState, SlabBlock.TYPE).orElse(SlabType.DOUBLE); + + if (targetSlabType == SlabType.DOUBLE) { + return super.getPossibleSides(); + } + + Direction[] directionsToCheck = { + Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST + }; + + for (Direction direction : directionsToCheck) { + SlabType neighborSlabType = getProperty(state.offset(direction).currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE); + + if (neighborSlabType == SlabType.DOUBLE || neighborSlabType == targetSlabType) { + resultList.add(direction); + } + } + + if (targetSlabType == SlabType.TOP || targetSlabType == SlabType.BOTTOM) { + Direction verticalDirection = targetSlabType == SlabType.TOP ? Direction.UP : Direction.DOWN; + SlabType neighborSlabType = getProperty(state.offset(verticalDirection).currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE); + + if (neighborSlabType == SlabType.DOUBLE || neighborSlabType != targetSlabType) { + resultList.add(verticalDirection); + } + } + + return resultList; } @Override