From 33b1f7b4743db58d179bcbc9de3a5c5920e6a5de Mon Sep 17 00:00:00 2001 From: bruned <30997009+bruned12@users.noreply.github.com> Date: Sun, 20 Aug 2023 22:04:53 +0800 Subject: [PATCH] Update SlabGuide.java Fix cant place slab --- .../v1_20/guides/placement/SlabGuide.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/SlabGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/SlabGuide.java index 449a5c8af..432f873fe 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/SlabGuide.java +++ b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/SlabGuide.java @@ -17,10 +17,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