zh_cn:tutorial:waterloggable
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| zh_cn:tutorial:waterloggable [2022/12/16 02:12] – solidblock | zh_cn:tutorial:waterloggable [2024/10/27 14:59] (current) – 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: | ||
| 覆盖 '' | 覆盖 '' | ||
| + | |||
| + | //1.21.2 之前的版本,请这么写:// | ||
| < | < | ||
| @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)) { | ||
| - | // 1.17 之前是这么写的:world.getFluidTickScheduler().schedule(pos, | + | // 对于 |
| + | // world.getFluidTickScheduler().schedule(pos, | ||
| + | // 对于 1.18 之后、1.21.2 之前的版本: | ||
| world.method_39281(pos, | world.method_39281(pos, | ||
| } | } | ||
| return super.getStateForNeighborUpdate(state, | return super.getStateForNeighborUpdate(state, | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | //1.21.2 以及更高的版本,请这么写:// | ||
| + | < | ||
| + | @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, | ||
| } | } | ||
| </ | </ | ||
| 现在方块可含水了,并且与水有关的功能都能正常运作。 | 现在方块可含水了,并且与水有关的功能都能正常运作。 | ||
zh_cn/tutorial/waterloggable.1671156767.txt.gz · Last modified: 2022/12/16 02:12 by solidblock