refactor package

This commit is contained in:
2025-08-22 05:14:59 +08:00
parent bec0a56a3d
commit 65690e51ab
371 changed files with 835 additions and 627 deletions

View File

@ -0,0 +1,35 @@
package client
import (
"io"
pk "github.com/Tnze/go-mc/net/packet"
)
type StopSound struct {
Flags int8
Source int32 `mc:"VarInt"`
Sound string `mc:"Identifier"`
}
func (s StopSound) WriteTo(w io.Writer) (n int64, err error) {
pk.Byte(s.Flags).WriteTo(w)
if s.Flags&0x01 != 0 {
pk.VarInt(s.Source).WriteTo(w)
}
if s.Flags&0x02 != 0 {
pk.Identifier(s.Sound).WriteTo(w)
}
return
}
func (s *StopSound) ReadFrom(r io.Reader) (n int64, err error) {
(*pk.Byte)(&s.Flags).ReadFrom(r)
if s.Flags&0x01 != 0 {
(*pk.VarInt)(&s.Source).ReadFrom(r)
}
if s.Flags&0x02 != 0 {
(*pk.Identifier)(&s.Sound).ReadFrom(r)
}
return
}