Record TagType when decoding RawMessage.
Display item's NBT in example/daze. Upgrade data/item to 1.17
This commit is contained in:
4459
data/item/item.go
4459
data/item/item.go
File diff suppressed because it is too large
Load Diff
@ -104,7 +104,7 @@ func onScreenSlotChange(id, index int) error {
|
||||
slot := container.(*screen.Inventory).Slots[index]
|
||||
itemInfo := item.ByID[item.ID(slot.ID)]
|
||||
if slot.ID != 0 {
|
||||
log.Printf("Slot: Screen[%d].Slot[%d]: [%v] * %d", id, index, itemInfo.DisplayName, slot.Count)
|
||||
log.Printf("Slot: Screen[%d].Slot[%d]: [%v] * %d | NBT: %v", id, index, itemInfo.DisplayName, slot.Count, slot.NBT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package nbt
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type RawMessage struct {
|
||||
@ -29,6 +30,22 @@ func (m *RawMessage) Decode(tagType byte, r DecoderReader) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.Type = tagType
|
||||
m.Data = buf.Bytes()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m RawMessage) String() string {
|
||||
if m.Type == TagEnd {
|
||||
return "TagEnd"
|
||||
}
|
||||
var snbt StringifiedMessage
|
||||
var sb strings.Builder
|
||||
r := bytes.NewReader(m.Data)
|
||||
d := NewDecoder(r)
|
||||
err := snbt.encode(d, &sb, m.Type)
|
||||
if err != nil {
|
||||
return "Invalid"
|
||||
}
|
||||
return sb.String()
|
||||
}
|
||||
|
Reference in New Issue
Block a user