Add item DataComponent implements (part 3)
This commit is contained in:
29
level/component/blockentitydata.go
Normal file
29
level/component/blockentitydata.go
Normal 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 = (*BlockEntityData)(nil)
|
||||||
|
|
||||||
|
type BlockEntityData struct {
|
||||||
|
dynbt.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (BlockEntityData) ID() string {
|
||||||
|
return "minecraft:block_entity_data"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (b *BlockEntityData) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return pk.NBT(&b.Value).ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (b *BlockEntityData) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return pk.NBT(&b.Value).WriteTo(w)
|
||||||
|
}
|
29
level/component/bucketentitydata.go
Normal file
29
level/component/bucketentitydata.go
Normal 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 = (*BucketEntityData)(nil)
|
||||||
|
|
||||||
|
type BucketEntityData struct {
|
||||||
|
dynbt.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (BucketEntityData) ID() string {
|
||||||
|
return "minecraft:bucket_entity_data"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (b *BucketEntityData) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return pk.NBT(&b.Value).ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (b *BucketEntityData) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return pk.NBT(&b.Value).WriteTo(w)
|
||||||
|
}
|
24
level/component/bundlecontents.go
Normal file
24
level/component/bundlecontents.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
var _ DataComponent = (*BundleContents)(nil)
|
||||||
|
|
||||||
|
type BundleContents struct {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (BundleContents) ID() string {
|
||||||
|
return "minecraft:bundle_contents"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (b *BundleContents) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (b *BundleContents) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
24
level/component/chargedprojectiles.go
Normal file
24
level/component/chargedprojectiles.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
var _ DataComponent = (*ChargedProjectiles)(nil)
|
||||||
|
|
||||||
|
type ChargedProjectiles struct {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (ChargedProjectiles) ID() string {
|
||||||
|
return "minecraft:charged_projectiles"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (c *ChargedProjectiles) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (c *ChargedProjectiles) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
29
level/component/debugstickstate.go
Normal file
29
level/component/debugstickstate.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/Tnze/go-mc/level/block"
|
||||||
|
pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ DataComponent = (*DebugStickState)(nil)
|
||||||
|
|
||||||
|
type DebugStickState struct {
|
||||||
|
Data block.State
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (DebugStickState) ID() string {
|
||||||
|
return "minecraft:debug_stick_state"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (d *DebugStickState) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return pk.NBT(&d.Data).ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (d *DebugStickState) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return pk.NBT(&d.Data).WriteTo(w)
|
||||||
|
}
|
29
level/component/entitydata.go
Normal file
29
level/component/entitydata.go
Normal 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 = (*EntityData)(nil)
|
||||||
|
|
||||||
|
type EntityData struct {
|
||||||
|
dynbt.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (EntityData) ID() string {
|
||||||
|
return "minecraft:entity_data"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (e *EntityData) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return pk.NBT(&e.Value).ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (e *EntityData) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return pk.NBT(&e.Value).WriteTo(w)
|
||||||
|
}
|
85
level/component/instrument.go
Normal file
85
level/component/instrument.go
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ DataComponent = (*Instrument)(nil)
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
type Instrument struct {
|
||||||
|
Type pk.VarInt
|
||||||
|
SoundEvent SoundEvent
|
||||||
|
UseDuration pk.Float
|
||||||
|
Range pk.Float
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (Instrument) ID() string {
|
||||||
|
return "minecraft:instrument"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (i *Instrument) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return pk.Tuple{
|
||||||
|
&i.Type,
|
||||||
|
pk.Opt{
|
||||||
|
Has: func() bool { return i.Type == 0 },
|
||||||
|
Field: pk.Tuple{
|
||||||
|
&i.SoundEvent,
|
||||||
|
&i.UseDuration,
|
||||||
|
&i.Range,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}.ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (i *Instrument) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return pk.Tuple{
|
||||||
|
&i.Type,
|
||||||
|
pk.Opt{
|
||||||
|
Has: func() bool { return i.Type == 0 },
|
||||||
|
Field: pk.Tuple{
|
||||||
|
&i.SoundEvent,
|
||||||
|
&i.UseDuration,
|
||||||
|
&i.Range,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}.WriteTo(w)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
type SoundEvent struct {
|
||||||
|
Type pk.VarInt
|
||||||
|
SoundName pk.Identifier
|
||||||
|
FixedRange pk.Option[pk.Float, *pk.Float]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SoundEvent) ReadFrom(r io.Reader) (int64, error) {
|
||||||
|
return pk.Tuple{
|
||||||
|
&s.Type,
|
||||||
|
pk.Opt{
|
||||||
|
Has: func() bool { return s.Type == 0 },
|
||||||
|
Field: pk.Tuple{
|
||||||
|
&s.SoundName,
|
||||||
|
&s.FixedRange,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}.ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SoundEvent) WriteTo(w io.Writer) (int64, error) {
|
||||||
|
return pk.Tuple{
|
||||||
|
&s.Type,
|
||||||
|
pk.Opt{
|
||||||
|
Has: func() bool { return s.Type == 0 },
|
||||||
|
Field: pk.Tuple{
|
||||||
|
&s.SoundName,
|
||||||
|
&s.FixedRange,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}.WriteTo(w)
|
||||||
|
}
|
31
level/component/mappostprogressing.go
Normal file
31
level/component/mappostprogressing.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ DataComponent = (*MapPostProcessing)(nil)
|
||||||
|
|
||||||
|
type MapPostProcessing int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
Lock MapPostProcessing = iota
|
||||||
|
Scale
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (MapPostProcessing) ID() string {
|
||||||
|
return "minecraft:map_post_processing"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (m *MapPostProcessing) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return (*pk.VarInt)(m).ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (m *MapPostProcessing) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return (*pk.VarInt)(m).WriteTo(w)
|
||||||
|
}
|
30
level/component/potioncontents.go
Normal file
30
level/component/potioncontents.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ DataComponent = (*PotionContents)(nil)
|
||||||
|
|
||||||
|
type PotionContents struct {
|
||||||
|
PotionID pk.Option[pk.VarInt, *pk.VarInt]
|
||||||
|
CustomColor pk.Option[pk.Int, *pk.Int]
|
||||||
|
PotionEffects []any
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (PotionContents) ID() string {
|
||||||
|
return "minecraft:potion_contents"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (p *PotionContents) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (p *PotionContents) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
26
level/component/suspicioussteweffects.go
Normal file
26
level/component/suspicioussteweffects.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ DataComponent = (*SuspiciousStewEffects)(nil)
|
||||||
|
|
||||||
|
type SuspiciousStewEffects struct {
|
||||||
|
Effects []any
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (SuspiciousStewEffects) ID() string {
|
||||||
|
return "minecraft:suspicious_stew_effects"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (s *SuspiciousStewEffects) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (s *SuspiciousStewEffects) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
24
level/component/trim.go
Normal file
24
level/component/trim.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
var _ DataComponent = (*Trim)(nil)
|
||||||
|
|
||||||
|
type Trim struct {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (Trim) ID() string {
|
||||||
|
return "minecraft:trim"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (t *Trim) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (t *Trim) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
33
level/component/writablebookcontent.go
Normal file
33
level/component/writablebookcontent.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ DataComponent = (*WritableBookContent)(nil)
|
||||||
|
|
||||||
|
type WritableBookContent struct {
|
||||||
|
Pages []Page
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (w *WritableBookContent) ID() string {
|
||||||
|
return "minecraft:writable_book_content"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (w *WritableBookContent) ReadFrom(reader io.Reader) (n int64, err error) {
|
||||||
|
return pk.Array(&w.Pages).ReadFrom(reader)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (w *WritableBookContent) WriteTo(writer io.Writer) (n int64, err error) {
|
||||||
|
return pk.Array(&w.Pages).WriteTo(writer)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Page struct {
|
||||||
|
Raw pk.String
|
||||||
|
Filtered pk.Option[pk.String, *pk.String]
|
||||||
|
}
|
Reference in New Issue
Block a user