-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add item DataComponent implements (part 3)
- Loading branch information
Showing
12 changed files
with
393 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
Oops, something went wrong.