Skip to content

Commit

Permalink
Add item DataComponent implements (part 4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tnze committed Jul 28, 2024
1 parent 76ff3a8 commit a5fbf35
Show file tree
Hide file tree
Showing 17 changed files with 519 additions and 422 deletions.
58 changes: 29 additions & 29 deletions level/component/blockentitydata.go
Original file line number Diff line number Diff line change
@@ -1,29 +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)
}
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)
}
58 changes: 29 additions & 29 deletions level/component/bucketentitydata.go
Original file line number Diff line number Diff line change
@@ -1,29 +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)
}
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)
}
48 changes: 24 additions & 24 deletions level/component/bundlecontents.go
Original file line number Diff line number Diff line change
@@ -1,24 +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")
}
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")
}
48 changes: 24 additions & 24 deletions level/component/chargedprojectiles.go
Original file line number Diff line number Diff line change
@@ -1,24 +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")
}
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")
}
15 changes: 15 additions & 0 deletions level/component/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,38 @@ func NewComponent(id int32) DataComponent {
case 27:
return new(MapDecorations)
case 28:
return new(MapPostProcessing)
case 29:
return new(ChargedProjectiles)
case 30:
return new(BundleContents)
case 31:
return new(PotionContents)
case 32:
return new(SuspiciousStewEffects)
case 33:
return new(WritableBookContent)
case 34:
case 35:
return new(Trim)
case 36:
return new(DebugStickState)
case 37:
return new(EntityData)
case 38:
return new(BucketEntityData)
case 39:
return new(BlockEntityData)
case 40:
return new(Instrument)
case 41:
return new(OminousBottleAmplifier)
case 42:
return new(JukeboxPlayable)
case 43:
return new(Recipes)
case 44:
return new(LodestoneTracker)
case 45:
case 46:
case 47:
Expand Down
58 changes: 29 additions & 29 deletions level/component/debugstickstate.go
Original file line number Diff line number Diff line change
@@ -1,29 +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)
}
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)
}
58 changes: 29 additions & 29 deletions level/component/entitydata.go
Original file line number Diff line number Diff line change
@@ -1,29 +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)
}
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)
}
Loading

0 comments on commit a5fbf35

Please sign in to comment.