Fix bot screen item counts

This commit is contained in:
Tnze
2024-07-28 16:42:08 +08:00
parent 330d7e6c3e
commit 966f50eb53

View File

@ -191,7 +191,7 @@ func (m *Manager) onSetSlot(p pk.Packet) (err error) {
type Slot struct { type Slot struct {
ID pk.VarInt ID pk.VarInt
Count pk.Byte Count pk.VarInt
NBT nbt.RawMessage NBT nbt.RawMessage
} }
@ -208,12 +208,15 @@ func (s *Slot) WriteTo(w io.Writer) (n int64, err error) {
} }
func (s *Slot) ReadFrom(r io.Reader) (n int64, err error) { func (s *Slot) ReadFrom(r io.Reader) (n int64, err error) {
var present pk.Boolean var componentsAdd, componentsRemove pk.VarInt
return pk.Tuple{ return pk.Tuple{
&present, pk.Opt{ &s.Count, pk.Opt{
Has: &present, Has: func() bool { return s.Count > 0 },
Field: pk.Tuple{ Field: pk.Tuple{
&s.ID, &s.Count, pk.NBT(&s.NBT), &s.ID,
&componentsAdd,
&componentsRemove,
// TODO: Components Ignored
}, },
}, },
}.ReadFrom(r) }.ReadFrom(r)