Add warning if sound index is unknown instead of panic
This commit is contained in:
@ -322,10 +322,14 @@ func handleSoundEffect(c *Client, p pk.Packet) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.Events.SoundPlay != nil {
|
if c.Events.SoundPlay != nil {
|
||||||
return c.Events.SoundPlay(
|
if int(s.Sound) < len(data.SoundNames) {
|
||||||
data.SoundNames[s.Sound], int(s.Category),
|
return c.Events.SoundPlay(
|
||||||
float64(s.X)/8, float64(s.Y)/8, float64(s.Z)/8,
|
data.SoundNames[s.Sound], int(s.Category),
|
||||||
float32(s.Volume), float32(s.Pitch))
|
float64(s.X)/8, float64(s.Y)/8, float64(s.Z)/8,
|
||||||
|
float32(s.Volume), float32(s.Pitch))
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(os.Stderr, "WARN: Unknown sound name. is data.SoundNames out of date?\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user