STATUS:
AUTHOR:
ASSIGNEE:
CREATED:
TITLE_
TAGS_ (comma separated)
Discussions
LEAVE_A_REPLY_
public boolean setBlockState(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) { ... BlockState blockState = worldChunk.setBlockState(pos, state, (flags & Block.MOVED) != 0); if (blockState != null) { BlockState blockState2 = this.getBlockState(pos); if (blockState2 == state) { ... // 由 FLAG 控制的 NC 更新的调用 if ((flags & Block.NOTIFY_NEIGHBORS) != 0) { this.updateNeighbors(pos, blockState.getBlock()); if (!this.isClient && state.hasComparatorOutput()) { this.updateComparators(pos, block); } } // 由 FLAG 控制的 PP 更新的调用 if ((flags & Block.FORCE_STATE) == 0 && maxUpdateDepth > 0) { int i = flags & ~(Block.NOTIFY_NEIGHBORS | Block.SKIP_DROPS); blockState.prepare(this, pos, i, maxUpdateDepth - 1); state.updateNeighbors(this, pos, i, maxUpdateDepth - 1); state.prepare(this, pos, i, maxUpdateDepth - 1); } ... } return true; } return false; }public static final Direction[] UPDATE_ORDER = new Direction[]{Direction.WEST, Direction.EAST, Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH};default public void updateNeighbors(BlockPos pos, Block sourceBlock, @Nullable Direction except) { for (Direction direction : UPDATE_ORDER) { if (direction == except) continue; this.updateNeighbor(pos.offset(direction), sourceBlock, pos); }}// 向周围方块广播方块更新事件public static final int NOTIFY_NEIGHBORS = 1;// 提醒需要对此方块改变做出反应的监听器和客户端public static final int NOTIFY_LISTENERS = 2;// 默认的方块变更时行为:与一起启用上述 NOTIFY_NEIGHBORS 和 NOTIFY_LISTENERS 同效。public static final int NOTIFY_ALL = 3;// 跳过更新,强制设置方块状态。public static final int FORCE_STATE = 16;