| 26 | } |
| 27 | |
| 28 | func (i *Interact) Encode(w encoding.Writer) error { |
| 29 | if err := w.VarInt(i.EntityId); err != nil { |
| 30 | return err |
| 31 | } |
| 32 | if err := w.VarInt(i.Type); err != nil { |
| 33 | return err |
| 34 | } |
| 35 | if i.Type == InteractTypeInteractAt { |
| 36 | if err := w.Float(i.TargetX); err != nil { |
| 37 | return err |
| 38 | } |
| 39 | if err := w.Float(i.TargetY); err != nil { |
| 40 | return err |
| 41 | } |
| 42 | if err := w.Float(i.TargetZ); err != nil { |
| 43 | return err |
| 44 | } |
| 45 | } |
| 46 | if i.Type == InteractTypeInteractAt || i.Type == InteractTypeInteract { |
| 47 | if err := w.VarInt(i.Hand); err != nil { |
| 48 | return err |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return w.Bool(i.Sneaking) |
| 53 | } |
| 54 | |
| 55 | func (i *Interact) Decode(r encoding.Reader) error { |
| 56 | if _, err := r.VarInt(&i.EntityId); err != nil { |