tutorial:waterloggable
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tutorial:waterloggable [2022/01/31 01:04] – created solidblock | tutorial:waterloggable [2024/10/27 14:25] (current) – update solidblock | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| </ | </ | ||
| - | In this case, we store the '' | + | In this case, we store the '' |
| <code java> | <code java> | ||
| Line 17: | Line 17: | ||
| public VerticalSlabBlock(Settings settings) { | public VerticalSlabBlock(Settings settings) { | ||
| super(settings); | super(settings); | ||
| - | setDefaultState(this.stateManager.getDefaultState() | + | setDefaultState(getDefaultState() |
| .with(Properties.HORIZONTAL_FACING, | .with(Properties.HORIZONTAL_FACING, | ||
| - | .with(WATERLOGGED, | + | .with(WATERLOGGED, |
| } | } | ||
| | | ||
| // Make the block recognize the property, otherwise setting the property will through exceptions. | // Make the block recognize the property, otherwise setting the property will through exceptions. | ||
| @Override | @Override | ||
| - | protected void appendProperties(StateManager.Builder< | + | protected void appendProperties(StateManager.Builder< |
| - | | + | |
| } | } | ||
| </ | </ | ||
| 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, |
| } | } | ||
| </ | </ | ||
| - | |||
| Override '' | Override '' | ||
| Line 49: | Line 48: | ||
| Override '' | Override '' | ||
| - | <code java> | + | |
| + | //For versions 1.21.1 and below, write like this:// | ||
| + | <yarncode | ||
| @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)) { | ||
| - | world.getFluidTickScheduler().schedule(pos, | + | |
| + | // world.getFluidTickScheduler().schedule(pos, Fluids.WATER, | ||
| + | // For versions since 1.18 below 1.21.2: | ||
| + | world.method_39281(pos, Fluids.WATER, | ||
| } | } | ||
| return super.getStateForNeighborUpdate(state, | return super.getStateForNeighborUpdate(state, | ||
| } | } | ||
| - | </code> | + | </yarncode> |
| + | |||
| + | //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.1643591081.txt.gz · Last modified: 2022/01/31 01:04 by solidblock