tutorial:waterloggable
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:waterloggable [2022/02/07 05:48] – 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)) { | ||
- | // This is for 1.17 and below: world.getFluidTickScheduler().schedule(pos, | + | // For 1.17 and below: |
- | world.createAndScheduleFluidTick(pos, Fluids.WATER, | + | // world.getFluidTickScheduler().schedule(pos, |
+ | // 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.1644212929.txt.gz · Last modified: 2022/02/07 05:48 by solidblock