Skip to content

Commit

Permalink
Merge pull request #188 from bruned12/printer-1.20.1-3.2.1
Browse files Browse the repository at this point in the history
Fix cant place slab
  • Loading branch information
aleksilassila authored Oct 29, 2024
2 parents 98009a1 + 33b1f7b commit 2357b37
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,35 @@ public SlabGuide(SchematicBlockState state) {

@Override
protected List<Direction> 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<Direction> 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
Expand Down

0 comments on commit 2357b37

Please sign in to comment.