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

(cherry picked from commit 2357b37)
  • Loading branch information
aleksilassila committed Oct 29, 2024
1 parent ff7c319 commit efb864f
Showing 1 changed file with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -17,10 +18,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 efb864f

Please sign in to comment.