zh_cn:tutorial:waterloggable
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| zh_cn:tutorial:waterloggable [2024/08/24 14:24] – 更新代码 solidblock | zh_cn:tutorial:waterloggable [2024/10/27 14:59] (current) – solidblock | ||
|---|---|---|---|
| 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.1724509461.txt.gz · Last modified: 2024/08/24 14:24 by solidblock