Add item DataComponent implements (part 2)
This commit is contained in:
38
level/component/storedenchantments.go
Normal file
38
level/component/storedenchantments.go
Normal file
@ -0,0 +1,38 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
pk "github.com/Tnze/go-mc/net/packet"
|
||||
)
|
||||
|
||||
var _ DataComponent = (*StoredEnchantments)(nil)
|
||||
|
||||
type StoredEnchantments struct {
|
||||
Enchantments []struct {
|
||||
Type pk.VarInt
|
||||
Level pk.VarInt
|
||||
}
|
||||
ShowInTooltip pk.Boolean
|
||||
}
|
||||
|
||||
// ID implements DataComponent.
|
||||
func (StoredEnchantments) ID() string {
|
||||
return "minecraft:stored_enchantments"
|
||||
}
|
||||
|
||||
// ReadFrom implements DataComponent.
|
||||
func (s *StoredEnchantments) ReadFrom(r io.Reader) (n int64, err error) {
|
||||
return pk.Tuple{
|
||||
pk.Array(&s.Enchantments),
|
||||
&s.ShowInTooltip,
|
||||
}.ReadFrom(r)
|
||||
}
|
||||
|
||||
// WriteTo implements DataComponent.
|
||||
func (s *StoredEnchantments) WriteTo(w io.Writer) (n int64, err error) {
|
||||
return pk.Tuple{
|
||||
pk.Array(&s.Enchantments),
|
||||
&s.ShowInTooltip,
|
||||
}.WriteTo(w)
|
||||
}
|
Reference in New Issue
Block a user