Skip to content

Commit d68a38f

Browse files
authored
world/world.go: Fixed spawn points in other dimensions, closes #1102. (#1143)
1 parent 76d8598 commit d68a38f

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

server/world/tick.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (t ticker) tick(tx *Tx) {
4040
w := tx.World()
4141

4242
w.set.Lock()
43-
if s := w.set.Spawn; s[1] > tx.Range()[1] {
43+
if s := w.set.Spawn; s[1] > tx.Range()[1] && w.Dimension() == Overworld {
4444
// Vanilla will set the spawn position's Y value to max to indicate that
4545
// the player should spawn at the highest position in the world.
4646
w.set.Spawn[1] = w.highestObstructingBlock(s[0], s[2]) + 1

server/world/world.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,13 @@ func (w *World) Spawn() cube.Pos {
779779
if w == nil {
780780
return cube.Pos{}
781781
}
782+
783+
if w.Dimension() == End {
784+
return cube.Pos{100, 50}
785+
} else if w.Dimension() == Nether {
786+
return cube.Pos{}
787+
}
788+
782789
w.set.Lock()
783790
defer w.set.Unlock()
784791
return w.set.Spawn
@@ -790,6 +797,12 @@ func (w *World) SetSpawn(pos cube.Pos) {
790797
if w == nil {
791798
return
792799
}
800+
801+
// nether has no spawn point and end spawn point is always 100 50 0.
802+
if w.Dimension() == Nether || w.Dimension() == End {
803+
return
804+
}
805+
793806
w.set.Lock()
794807
w.set.Spawn = pos
795808
w.set.Unlock()

0 commit comments

Comments
 (0)