Add nbt.RawMessage
This commit is contained in:
23
nbt/raw.go
Normal file
23
nbt/raw.go
Normal file
@ -0,0 +1,23 @@
|
||||
package nbt
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
)
|
||||
|
||||
type RawMessage []byte
|
||||
|
||||
func (m *RawMessage) Unmarshal(tagType byte, _ string, r DecoderReader) error {
|
||||
if tagType == TagEnd {
|
||||
return ErrEND
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer((*m)[:0])
|
||||
tee := io.TeeReader(r, buf)
|
||||
err := NewDecoder(tee).rawRead(tagType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*m = buf.Bytes()
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user