Skip to content

Commit 81503f5

Browse files
committed
fix upper state of placed slopes
1 parent e1a2a67 commit 81503f5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

common/src/main/java/one/devos/nautical/losing_my_marbles/content/piece/slope/SlopePieceBlockItem.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package one.devos.nautical.losing_my_marbles.content.piece.slope;
22

33
import net.minecraft.core.BlockPos;
4+
import net.minecraft.core.Direction;
45
import net.minecraft.world.item.BlockItem;
56
import net.minecraft.world.item.context.BlockPlaceContext;
67
import net.minecraft.world.level.Level;
@@ -19,9 +20,16 @@ protected boolean placeBlock(BlockPlaceContext context, BlockState state) {
1920
BlockPos pos = context.getClickedPos();
2021
BlockPos upperPos = SlopePieceBlock.getOtherHalfPos(state, pos);
2122
boolean placedUpper = false;
23+
2224
if (upperPos.getY() <= level.getMaxY() && level.getBlockState(upperPos).canBeReplaced(context)) {
23-
placedUpper = level.setBlock(upperPos, state.setValue(SlopePieceBlock.HALF, DoubleBlockHalf.UPPER), Block.UPDATE_ALL_IMMEDIATE);
25+
BlockPlaceContext upperContext = BlockPlaceContext.at(context, upperPos, Direction.UP);
26+
BlockState upperState = state.getBlock().getStateForPlacement(upperContext);
27+
if (upperState != null) {
28+
upperState = upperState.setValue(SlopePieceBlock.HALF, DoubleBlockHalf.UPPER);
29+
placedUpper = level.setBlock(upperPos, upperState, Block.UPDATE_ALL_IMMEDIATE);
30+
}
2431
}
32+
2533
return placedUpper && super.placeBlock(context, state);
2634
}
2735
}

0 commit comments

Comments
 (0)