Skip to content

Commit

Permalink
world/tick.go: Fixed newly scheduled neighbour updates being ticked i…
Browse files Browse the repository at this point in the history
…mmediately.
  • Loading branch information
Sandertv committed Nov 24, 2024
1 parent 9cceaef commit 6d34bd4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/world/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ func (t ticker) tickScheduledBlocks(tx *Tx, tick int64) {

// performNeighbourUpdates performs all block updates that came as a result of a neighbouring block being changed.
func (t ticker) performNeighbourUpdates(tx *Tx) {
for _, update := range tx.World().neighbourUpdates {
updates := slices.Clone(tx.World().neighbourUpdates)
clear(tx.World().neighbourUpdates)
tx.World().neighbourUpdates = tx.World().neighbourUpdates[:0]

for _, update := range updates {
pos, changedNeighbour := update.pos, update.neighbour
if ticker, ok := tx.Block(pos).(NeighbourUpdateTicker); ok {
ticker.NeighbourUpdateTick(pos, changedNeighbour, tx)
Expand All @@ -107,8 +111,6 @@ func (t ticker) performNeighbourUpdates(tx *Tx) {
}
}
}
clear(tx.World().neighbourUpdates)
tx.World().neighbourUpdates = tx.World().neighbourUpdates[:0]
}

// tickBlocksRandomly executes random block ticks in each sub chunk in the world that has at least one viewer
Expand Down

0 comments on commit 6d34bd4

Please sign in to comment.