Add item DataComponent implements (part 1)

This commit is contained in:
Tnze
2024-07-28 17:52:41 +08:00
parent 966f50eb53
commit 090493c4ac
26 changed files with 860 additions and 256 deletions

View File

@ -0,0 +1,29 @@
package component
import (
"io"
"github.com/Tnze/go-mc/nbt/dynbt"
pk "github.com/Tnze/go-mc/net/packet"
)
var _ DataComponent = (*CustomData)(nil)
type CustomData struct {
dynbt.Value
}
// ID implements DataComponent.
func (CustomData) ID() string {
return "minecraft:custom_data"
}
// ReadFrom implements DataComponent.
func (c *CustomData) ReadFrom(r io.Reader) (n int64, err error) {
return pk.NBT(c).ReadFrom(r)
}
// WriteTo implements DataComponent.
func (c *CustomData) WriteTo(w io.Writer) (n int64, err error) {
return pk.NBT(c).WriteTo(w)
}