pk.Ary and pk.Array using generic now

This commit is contained in:
Tnze
2022-03-20 01:17:25 +08:00
parent 7997a5faea
commit 4c2510565d
15 changed files with 95 additions and 155 deletions

View File

@ -140,6 +140,14 @@ func (p *PaletteContainer) ReadFrom(r io.Reader) (n int64, err error) {
return n, nil
}
func (p *PaletteContainer) WriteTo(w io.Writer) (n int64, err error) {
return pk.Tuple{
pk.UnsignedByte(p.bits),
p.palette,
p.data,
}.WriteTo(w)
}
type paletteCfg interface {
bits(int) int
create(bits int) palette
@ -197,14 +205,6 @@ func (b biomesCfg) create(bits int) palette {
}
}
func (p *PaletteContainer) WriteTo(w io.Writer) (n int64, err error) {
return pk.Tuple{
pk.UnsignedByte(p.bits),
p.palette,
p.data,
}.WriteTo(w)
}
type palette interface {
pk.Field
id(v state) (int, bool)