Skip to content

Commit

Permalink
Merge pull request Anvil-Dev#228 from Gu-ZT/ChuteBlock
Browse files Browse the repository at this point in the history
不允许对向放置溜槽
  • Loading branch information
Gu-ZT authored Apr 12, 2024
2 parents 780c9f9 + 57039f7 commit e412946
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 e412946

Please sign in to comment.