Skip to content

Commit

Permalink
不允许对向放置溜槽
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Apr 12, 2024
1 parent 347626e commit 57039f7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,14 @@ public void onRemove(@NotNull BlockState state, @NotNull Level level, @NotNull B
}

@Override
public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) {
@SuppressWarnings("deprecation")
public void onPlace(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState oldState, boolean movedByPiston) {
BlockState facingState = level.getBlockState(pos.relative(state.getValue(FACING)));
if (facingState.is(ModBlocks.CHUTE.get()) || facingState.is(ModBlocks.SIMPLE_CHUTE.get())) {
if (facingState.getValue(FACING).getOpposite() == state.getValue(FACING)) {
level.destroyBlock(pos, true);
return;
}
BlockState newState = ModBlocks.SIMPLE_CHUTE.getDefaultState();
newState = newState
.setValue(SimpleChuteBlock.FACING, facingState.getValue(FACING))
Expand Down

0 comments on commit 57039f7

Please sign in to comment.