Implement packet decoding for entities

This commit is contained in:
Tom
2020-09-17 00:13:08 -07:00
parent a981ab84f5
commit 8ecf08fa50
4 changed files with 270 additions and 19 deletions

View File

@ -2,10 +2,11 @@ package packet
import (
"errors"
"github.com/google/uuid"
"io"
"math"
"github.com/google/uuid"
"github.com/Tnze/go-mc/nbt"
)
@ -364,6 +365,16 @@ func (p *Position) Decode(r DecodeReader) error {
return nil
}
//Decodes an Angle
func (b *Angle) Decode(r DecodeReader) error {
v, err := r.ReadByte()
if err != nil {
return err
}
*b = Angle(v)
return nil
}
//Encode a Float
func (f Float) Encode() []byte {
return Int(math.Float32bits(float32(f))).Encode()