github.com/df-mc/dragonfly@v0.9.13/server/session/handler_respawn.go (about) 1 package session 2 3 import ( 4 "fmt" 5 "github.com/sandertv/gophertunnel/minecraft/protocol/packet" 6 ) 7 8 // RespawnHandler handles the Respawn packet. 9 type RespawnHandler struct{} 10 11 // Handle ... 12 func (*RespawnHandler) Handle(p packet.Packet, s *Session) error { 13 pk := p.(*packet.Respawn) 14 15 if pk.EntityRuntimeID != selfEntityRuntimeID { 16 return errSelfRuntimeID 17 } 18 if pk.State != packet.RespawnStateClientReadyToSpawn { 19 return fmt.Errorf("respawn state must always be %v, but got %v", packet.RespawnStateClientReadyToSpawn, pk.State) 20 } 21 s.c.Respawn() 22 return nil 23 }