Skip to content

Commit

Permalink
- More adjustment to updateBlock
Browse files Browse the repository at this point in the history
 - Flag 64 and neighbor updates were causing blocks to break that shouldn't break.
  • Loading branch information
copperwarrior committed Nov 14, 2022
1 parent 970bbbf commit 49f473a
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,28 @@ fun relocateBlock(
*/
fun updateBlock(level: Level, fromPos: BlockPos, toPos: BlockPos, toState: BlockState) {

// 75 = flag 1 (block update) & flag 2 (send to clients) + flag 8 (force rerenders) + flag 64 (block is moving)
val flags = 75
// 75 = flag 1 (block update) & flag 2 (send to clients) + flag 8 (force rerenders)
val flags = 11

// updateNeighbourShapes recurses through nearby blocks, recursionLeft is the limit
val recursionLeft = 511

level.setBlocksDirty(fromPos, toState, AIR)
level.sendBlockUpdated(fromPos, toState, AIR, flags)
level.blockUpdated(fromPos, AIR.block)
// This handles the update for neighboring blocks in worldspace
AIR.updateIndirectNeighbourShapes(level, fromPos, flags, recursionLeft - 1);
AIR.updateNeighbourShapes(level, fromPos, flags, recursionLeft)
AIR.updateIndirectNeighbourShapes(level, fromPos, flags, recursionLeft)
// This updates lighting for blocks in worldspace
level.chunkSource.lightEngine.checkBlock(fromPos)

level.setBlocksDirty(toPos, AIR, toState)
level.sendBlockUpdated(toPos, AIR, toState, flags)
// This handles the update for neighboring blocks in shipspace (ladders, redstone)
toState.updateNeighbourShapes(level, toPos, flags, recursionLeft)
toState.updateIndirectNeighbourShapes(level, toPos, flags, recursionLeft)
level.blockUpdated(toPos, toState.block)
if (!level.isClientSide && toState.hasAnalogOutputSignal()) {
level.updateNeighbourForOutputSignal(toPos, toState.block)
}
// This updates lighting for blocks in shipspace
level.chunkSource.lightEngine.checkBlock(toPos)
}
Expand Down

0 comments on commit 49f473a

Please sign in to comment.