33 lines
992 B
Go
33 lines
992 B
Go
|
|
package block_test
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"github.com/df-mc/dragonfly/server/block"
|
||
|
|
"github.com/df-mc/dragonfly/server/block/cube"
|
||
|
|
"github.com/df-mc/dragonfly/server/entity"
|
||
|
|
"github.com/df-mc/dragonfly/server/world"
|
||
|
|
)
|
||
|
|
|
||
|
|
// TestTorchBreaksWithoutSupport verifies that a torch is broken by a neighbour
|
||
|
|
// update on the tick after its supporting block is removed, using a
|
||
|
|
// synchronous World to make the tick deterministic.
|
||
|
|
func TestTorchBreaksWithoutSupport(t *testing.T) {
|
||
|
|
w := world.Config{Synchronous: true, Entities: entity.DefaultRegistry}.New()
|
||
|
|
defer w.Close()
|
||
|
|
|
||
|
|
support, torch := cube.Pos{0, 0, 0}, cube.Pos{0, 1, 0}
|
||
|
|
<-w.Exec(func(tx *world.Tx) {
|
||
|
|
tx.SetBlock(support, block.Stone{}, nil)
|
||
|
|
tx.SetBlock(torch, block.Torch{Facing: cube.FaceDown}, nil)
|
||
|
|
tx.SetBlock(support, block.Air{}, nil)
|
||
|
|
})
|
||
|
|
w.AdvanceTick()
|
||
|
|
|
||
|
|
<-w.Exec(func(tx *world.Tx) {
|
||
|
|
if b := tx.Block(torch); b != (block.Air{}) {
|
||
|
|
t.Errorf("expected torch to break after removing its support, got %v", b)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|