tutorial:waterloggable
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:waterloggable [2023/09/06 08:21] – Fix syntax error drakonkinst | tutorial:waterloggable [2024/10/27 14:25] (current) – update solidblock | ||
|---|---|---|---|
| Line 19: | Line 19: | ||
| setDefaultState(getDefaultState() | setDefaultState(getDefaultState() | ||
| .with(Properties.HORIZONTAL_FACING, | .with(Properties.HORIZONTAL_FACING, | ||
| - | .with(WATERLOGGED, | + | .with(WATERLOGGED, |
| } | } | ||
| | | ||
| Line 33: | Line 33: | ||
| @Override | @Override | ||
| public BlockState getPlacementState(ItemPlacementContext ctx) { | public BlockState getPlacementState(ItemPlacementContext ctx) { | ||
| - | return | + | return this.getDefaultState() |
| - | .with(Properties.HORIZONTAL_FACING, | + | .with(Properties.HORIZONTAL_FACING, |
| .with(WATERLOGGED, | .with(WATERLOGGED, | ||
| } | } | ||
| Line 48: | Line 48: | ||
| Override '' | Override '' | ||
| + | |||
| + | //For versions 1.21.1 and below, write like this:// | ||
| < | < | ||
| @Override | @Override | ||
| public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, | public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, | ||
| if (state.get(WATERLOGGED)) { | if (state.get(WATERLOGGED)) { | ||
| - | // This is for 1.17 and below: world.getFluidTickScheduler().schedule(pos, | + | // For 1.17 and below: |
| + | // world.getFluidTickScheduler().schedule(pos, | ||
| + | // For versions since 1.18 below 1.21.2: | ||
| world.method_39281(pos, | world.method_39281(pos, | ||
| } | } | ||
| return super.getStateForNeighborUpdate(state, | return super.getStateForNeighborUpdate(state, | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | //For versions 1.21.2 and above, write like this:// | ||
| + | < | ||
| + | @Override | ||
| + | public BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, | ||
| + | if (state.get(WATERLOGGED)) { | ||
| + | // For versions since 1.21.2: | ||
| + | tickView.scheduleFluidTick(pos, | ||
| + | } | ||
| + | |||
| + | return super.getStateForNeighborUpdate(state, | ||
| } | } | ||
| </ | </ | ||
| Now the block becomes waterloggable, | Now the block becomes waterloggable, | ||
tutorial/waterloggable.1693988495.txt.gz · Last modified: 2023/09/06 08:21 by drakonkinst