Add item DataComponent implements (part 2)
This commit is contained in:
@ -46,15 +46,25 @@ func NewComponent(id int32) DataComponent {
|
|||||||
case 17:
|
case 17:
|
||||||
return new(CreativeSlotLock)
|
return new(CreativeSlotLock)
|
||||||
case 18:
|
case 18:
|
||||||
|
return new(EnchantmentGlintOverride)
|
||||||
case 19:
|
case 19:
|
||||||
|
return new(IntangibleProjectile)
|
||||||
case 20:
|
case 20:
|
||||||
|
return new(Food)
|
||||||
case 21:
|
case 21:
|
||||||
|
return new(FireResistant)
|
||||||
case 22:
|
case 22:
|
||||||
|
return new(Tool)
|
||||||
case 23:
|
case 23:
|
||||||
|
return new(StoredEnchantments)
|
||||||
case 24:
|
case 24:
|
||||||
|
return new(DyedColor)
|
||||||
case 25:
|
case 25:
|
||||||
|
return new(MapColor)
|
||||||
case 26:
|
case 26:
|
||||||
|
return new(MapID)
|
||||||
case 27:
|
case 27:
|
||||||
|
return new(MapDecorations)
|
||||||
case 28:
|
case 28:
|
||||||
case 29:
|
case 29:
|
||||||
case 30:
|
case 30:
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import (
|
import "io"
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ DataComponent = (*CreativeSlotLock)(nil)
|
var _ DataComponent = (*CreativeSlotLock)(nil)
|
||||||
|
|
||||||
|
@ -1,28 +1,14 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import (
|
import pk "github.com/Tnze/go-mc/net/packet"
|
||||||
"io"
|
|
||||||
|
|
||||||
pk "github.com/Tnze/go-mc/net/packet"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ DataComponent = (*Damage)(nil)
|
var _ DataComponent = (*Damage)(nil)
|
||||||
|
|
||||||
type Damage struct {
|
type Damage struct {
|
||||||
Damage pk.VarInt
|
pk.VarInt
|
||||||
}
|
}
|
||||||
|
|
||||||
// ID implements DataComponent.
|
// ID implements DataComponent.
|
||||||
func (Damage) ID() string {
|
func (Damage) ID() string {
|
||||||
return "minecraft:damage"
|
return "minecraft:damage"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFrom implements DataComponent.
|
|
||||||
func (d *Damage) ReadFrom(r io.Reader) (n int64, err error) {
|
|
||||||
return d.Damage.ReadFrom(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WriteTo implements DataComponent.
|
|
||||||
func (d *Damage) WriteTo(w io.Writer) (n int64, err error) {
|
|
||||||
return d.Damage.WriteTo(w)
|
|
||||||
}
|
|
||||||
|
29
level/component/dyedcolor.go
Normal file
29
level/component/dyedcolor.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ DataComponent = (*DyedColor)(nil)
|
||||||
|
|
||||||
|
type DyedColor struct {
|
||||||
|
RGB pk.Int
|
||||||
|
ShowInTooltip pk.Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (DyedColor) ID() string {
|
||||||
|
return "minecraft:dyed_color"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (d *DyedColor) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return pk.Tuple{&d.RGB, &d.ShowInTooltip}.ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (d *DyedColor) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return pk.Tuple{&d.RGB, &d.ShowInTooltip}.WriteTo(w)
|
||||||
|
}
|
28
level/component/enchantmentglintoverride.go
Normal file
28
level/component/enchantmentglintoverride.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ DataComponent = (*EnchantmentGlintOverride)(nil)
|
||||||
|
|
||||||
|
type EnchantmentGlintOverride struct {
|
||||||
|
HasGlint pk.Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (EnchantmentGlintOverride) ID() string {
|
||||||
|
return "minecraft:enchantment_glint_override"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (e *EnchantmentGlintOverride) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return e.HasGlint.ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (e *EnchantmentGlintOverride) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return e.HasGlint.WriteTo(w)
|
||||||
|
}
|
22
level/component/fireresistant.go
Normal file
22
level/component/fireresistant.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
var _ DataComponent = (*FireResistant)(nil)
|
||||||
|
|
||||||
|
type FireResistant struct{}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (FireResistant) ID() string {
|
||||||
|
return "minecraft:fire_resistant"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (f *FireResistant) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (f *FireResistant) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
47
level/component/food.go
Normal file
47
level/component/food.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ DataComponent = (*Food)(nil)
|
||||||
|
|
||||||
|
type Food struct {
|
||||||
|
Nutrition pk.VarInt
|
||||||
|
Saturation pk.Float
|
||||||
|
CanAlwaysEat pk.Boolean
|
||||||
|
EatSeconds pk.Float
|
||||||
|
// TODO: using_converts_to
|
||||||
|
// TODO: effects
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (Food) ID() string {
|
||||||
|
return "minecraft:food"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (f *Food) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
pk.Tuple{
|
||||||
|
&f.Nutrition,
|
||||||
|
&f.Saturation,
|
||||||
|
&f.CanAlwaysEat,
|
||||||
|
&f.EatSeconds,
|
||||||
|
// TODO
|
||||||
|
}.ReadFrom(r)
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (f *Food) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
pk.Tuple{
|
||||||
|
&f.Nutrition,
|
||||||
|
&f.Saturation,
|
||||||
|
&f.CanAlwaysEat,
|
||||||
|
&f.EatSeconds,
|
||||||
|
// TODO
|
||||||
|
}.WriteTo(w)
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
@ -1,8 +1,6 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import (
|
import "io"
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ DataComponent = (*HideAdditionalTooptip)(nil)
|
var _ DataComponent = (*HideAdditionalTooptip)(nil)
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import (
|
import "io"
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ DataComponent = (*HideTooptip)(nil)
|
var _ DataComponent = (*HideTooptip)(nil)
|
||||||
|
|
||||||
|
22
level/component/intangibleprojectile.go
Normal file
22
level/component/intangibleprojectile.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
var _ DataComponent = (*IntangibleProjectile)(nil)
|
||||||
|
|
||||||
|
type IntangibleProjectile struct{}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (IntangibleProjectile) ID() string {
|
||||||
|
return "minecraft:intangible_projectile"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (i *IntangibleProjectile) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (i *IntangibleProjectile) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
15
level/component/mapcolor.go
Normal file
15
level/component/mapcolor.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
|
||||||
|
var _ DataComponent = (*MapColor)(nil)
|
||||||
|
|
||||||
|
type MapColor struct {
|
||||||
|
// The RGB components of the color, encoded as an integer.
|
||||||
|
pk.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (MapColor) ID() string {
|
||||||
|
return "minecraft:map_color"
|
||||||
|
}
|
29
level/component/mapdecorations.go
Normal file
29
level/component/mapdecorations.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 = (*MapDecorations)(nil)
|
||||||
|
|
||||||
|
type MapDecorations struct {
|
||||||
|
dynbt.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (MapDecorations) ID() string {
|
||||||
|
return "minecraft:map_decorations"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (m *MapDecorations) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
return pk.NBT(&m.Value).ReadFrom(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (m *MapDecorations) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
return pk.NBT(&m.Value).WriteTo(w)
|
||||||
|
}
|
14
level/component/mapid.go
Normal file
14
level/component/mapid.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import pk "github.com/Tnze/go-mc/net/packet"
|
||||||
|
|
||||||
|
var _ DataComponent = (*MapID)(nil)
|
||||||
|
|
||||||
|
type MapID struct {
|
||||||
|
pk.VarInt
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (MapID) ID() string {
|
||||||
|
return "minecraft:map_id"
|
||||||
|
}
|
@ -1,28 +1,14 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import (
|
import pk "github.com/Tnze/go-mc/net/packet"
|
||||||
"io"
|
|
||||||
|
|
||||||
pk "github.com/Tnze/go-mc/net/packet"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ DataComponent = (*MaxDamage)(nil)
|
var _ DataComponent = (*MaxDamage)(nil)
|
||||||
|
|
||||||
type MaxDamage struct {
|
type MaxDamage struct {
|
||||||
MaxDamage pk.VarInt
|
pk.VarInt
|
||||||
}
|
}
|
||||||
|
|
||||||
// ID implements DataComponent.
|
// ID implements DataComponent.
|
||||||
func (MaxDamage) ID() string {
|
func (MaxDamage) ID() string {
|
||||||
return "minecraft:max_damage"
|
return "minecraft:max_damage"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFrom implements DataComponent.
|
|
||||||
func (m *MaxDamage) ReadFrom(r io.Reader) (n int64, err error) {
|
|
||||||
return m.MaxDamage.ReadFrom(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WriteTo implements DataComponent.
|
|
||||||
func (m *MaxDamage) WriteTo(w io.Writer) (n int64, err error) {
|
|
||||||
return m.MaxDamage.WriteTo(w)
|
|
||||||
}
|
|
||||||
|
@ -1,28 +1,14 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import (
|
import pk "github.com/Tnze/go-mc/net/packet"
|
||||||
"io"
|
|
||||||
|
|
||||||
pk "github.com/Tnze/go-mc/net/packet"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ DataComponent = (*MaxStackSize)(nil)
|
var _ DataComponent = (*MaxStackSize)(nil)
|
||||||
|
|
||||||
type MaxStackSize struct {
|
type MaxStackSize struct {
|
||||||
MaxStackSize pk.VarInt
|
pk.VarInt
|
||||||
}
|
}
|
||||||
|
|
||||||
// ID implements DataComponent.
|
// ID implements DataComponent.
|
||||||
func (MaxStackSize) ID() string {
|
func (MaxStackSize) ID() string {
|
||||||
return "minecraft:max_stack_size"
|
return "minecraft:max_stack_size"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFrom implements DataComponent.
|
|
||||||
func (m *MaxStackSize) ReadFrom(r io.Reader) (n int64, err error) {
|
|
||||||
return m.MaxStackSize.ReadFrom(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WriteTo implements DataComponent.
|
|
||||||
func (m *MaxStackSize) WriteTo(w io.Writer) (n int64, err error) {
|
|
||||||
return m.MaxStackSize.WriteTo(w)
|
|
||||||
}
|
|
||||||
|
@ -1,28 +1,14 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import (
|
import pk "github.com/Tnze/go-mc/net/packet"
|
||||||
"io"
|
|
||||||
|
|
||||||
pk "github.com/Tnze/go-mc/net/packet"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ DataComponent = (*RepairCost)(nil)
|
var _ DataComponent = (*RepairCost)(nil)
|
||||||
|
|
||||||
type RepairCost struct {
|
type RepairCost struct {
|
||||||
Cost pk.VarInt
|
pk.VarInt
|
||||||
}
|
}
|
||||||
|
|
||||||
// ID implements DataComponent.
|
// ID implements DataComponent.
|
||||||
func (RepairCost) ID() string {
|
func (RepairCost) ID() string {
|
||||||
return "minecraft:repair_cost"
|
return "minecraft:repair_cost"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFrom implements DataComponent.
|
|
||||||
func (r *RepairCost) ReadFrom(reader io.Reader) (n int64, err error) {
|
|
||||||
return r.Cost.ReadFrom(reader)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WriteTo implements DataComponent.
|
|
||||||
func (r *RepairCost) WriteTo(writer io.Writer) (n int64, err error) {
|
|
||||||
return r.Cost.WriteTo(writer)
|
|
||||||
}
|
|
||||||
|
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)
|
||||||
|
}
|
22
level/component/tool.go
Normal file
22
level/component/tool.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
var _ DataComponent = (*Tool)(nil)
|
||||||
|
|
||||||
|
type Tool struct{}
|
||||||
|
|
||||||
|
// ID implements DataComponent.
|
||||||
|
func (Tool) ID() string {
|
||||||
|
return "minecraft:tool"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFrom implements DataComponent.
|
||||||
|
func (t *Tool) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo implements DataComponent.
|
||||||
|
func (t *Tool) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
Reference in New Issue
Block a user