Start implementing boilerplate for manipulating inventory

This commit is contained in:
Tom
2020-09-26 18:05:40 -07:00
parent 1a269d9b63
commit 670799df8d
4 changed files with 39 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import (
"errors"
"github.com/Tnze/go-mc/bot/world/entity"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/nbt"
pk "github.com/Tnze/go-mc/net/packet"
)
@ -52,3 +53,17 @@ func (p *WindowItems) Decode(pkt pk.Packet) error {
}
return nil
}
// OpenWindow is a clientbound packet which opens an inventory.
type OpenWindow struct {
WindowID pk.VarInt
WindowType pk.VarInt
Title chat.Message
}
func (p *OpenWindow) Decode(pkt pk.Packet) error {
if err := pkt.Scan(&p.WindowID, &p.WindowType, &p.Title); err != nil && !errors.Is(err, nbt.ErrEND) {
return err
}
return nil
}