func (t *EncryptionRequest) Decode(rr io.Reader) (err error) {
	if t.ServerID, err = packets.ReadString(rr); err != nil {
		return err
	}
	var tmp0 packets.VarInt
	tmp1, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	tmp0 = packets.VarInt(tmp1)

	if tmp0 < 0 {
		return fmt.Errorf("negative array size: %d < 0", tmp0)
	}
	t.PublicKey = make([]byte, tmp0)
	if _, err = rr.Read(t.PublicKey); err != nil {
		return err
	}
	var tmp2 packets.VarInt
	tmp3, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	tmp2 = packets.VarInt(tmp3)

	if tmp2 < 0 {
		return fmt.Errorf("negative array size: %d < 0", tmp2)
	}
	t.VerifyToken = make([]byte, tmp2)
	if _, err = rr.Read(t.VerifyToken); err != nil {
		return err
	}
	return
}
func (t *EncryptionResponse) Decode(rr io.Reader) (err error) {
	var tmp0 packets.VarInt
	tmp1, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	tmp0 = packets.VarInt(tmp1)

	if tmp0 < 0 {
		return fmt.Errorf("negative array size: %d < 0", tmp0)
	}
	t.SharedSecret = make([]byte, tmp0)
	if _, err = rr.Read(t.SharedSecret); err != nil {
		return err
	}
	var tmp2 packets.VarInt
	tmp3, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	tmp2 = packets.VarInt(tmp3)

	if tmp2 < 0 {
		return fmt.Errorf("negative array size: %d < 0", tmp2)
	}
	t.VerifyToken = make([]byte, tmp2)
	if _, err = rr.Read(t.VerifyToken); err != nil {
		return err
	}
	return
}
Example #3
0
func (t *Teams) Decode(rr io.Reader) (err error) {
	if t.Name, err = packets.ReadString(rr); err != nil {
		return err
	}
	if err = binary.Read(rr, binary.BigEndian, t.Mode); err != nil {
		return err
	}

	if t.Mode == 0 || t.Mode == 2 {
		if t.Display, err = packets.ReadString(rr); err != nil {
			return err
		}
	}
	if t.Mode == 0 || t.Mode == 2 {
		if t.Prefix, err = packets.ReadString(rr); err != nil {
			return err
		}
	}
	if t.Mode == 0 || t.Mode == 2 {
		if t.Suffix, err = packets.ReadString(rr); err != nil {
			return err
		}
	}
	if t.Mode == 0 || t.Mode == 2 {
		if err = binary.Read(rr, binary.BigEndian, t.FriendlyFire); err != nil {
			return err
		}

	}
	if t.Mode == 0 || t.Mode == 2 {
		if t.NameTagVisibility, err = packets.ReadString(rr); err != nil {
			return err
		}
	}
	if t.Mode == 0 || t.Mode == 2 {
		if err = binary.Read(rr, binary.BigEndian, t.Color); err != nil {
			return err
		}

	}
	if t.Mode == 0 || t.Mode == 3 || t.Mode == 4 {
		var tmp0 packets.VarInt
		tmp1, err := packets.ReadVarint(rr)
		if err != nil {
			return err
		}
		tmp0 = packets.VarInt(tmp1)

		if tmp0 < 0 {
			return fmt.Errorf("negative array size: %d < 0", tmp0)
		}
		t.Players = make([]string, tmp0)
		for tmp2 := range t.Players {
			if t.Players[tmp2], err = packets.ReadString(rr); err != nil {
				return err
			}
		}
	}
	return
}
Example #4
0
func (t *X) Decode(rr io.Reader) (err error) {
	var tmp0 packets.VarInt
	tmp1, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	tmp0 = packets.VarInt(tmp1)

	if tmp0 < 0 {
		return fmt.Errorf("negative array size: %d < 0", tmp0)
	}
	t.Ys = make([]Y, tmp0)
	for tmp2 := range t.Ys {
		var tmp3 [1]byte
		if _, err = rr.Read(tmp3[:1]); err != nil {
			return err
		}
		t.Ys[tmp2].A = tmp3[0] == 0x01

		if err = binary.Read(rr, binary.BigEndian, t.Ys[tmp2].B); err != nil {
			return err
		}

		if t.Ys[tmp2].A && t.Ys[tmp2].B == 1 {
			if err = binary.Read(rr, binary.BigEndian, t.Ys[tmp2].C); err != nil {
				return err
			}

		}
	}
	return
}
func (t *SetInitialCompression) Decode(rr io.Reader) (err error) {
	tmp0, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	t.Threshold = packets.VarInt(tmp0)

	return
}
Example #6
0
func (t *ClientStatus) Decode(rr io.Reader) (err error) {
	tmp0, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	t.ActionID = packets.VarInt(tmp0)

	return
}
Example #7
0
func (t *Handshake) Decode(rr io.Reader) (err error) {
	tmp0, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	t.ProtocolVersion = packets.VarInt(tmp0)

	if t.Address, err = packets.ReadString(rr); err != nil {
		return err
	}
	if err = binary.Read(rr, binary.BigEndian, t.Port); err != nil {
		return err
	}

	tmp1, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	t.NextState = packets.VarInt(tmp1)

	return
}
Example #8
0
func (t *ServerTabComplete) Decode(rr io.Reader) (err error) {
	var tmp0 packets.VarInt
	tmp1, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	tmp0 = packets.VarInt(tmp1)

	if tmp0 < 0 {
		return fmt.Errorf("negative array size: %d < 0", tmp0)
	}
	t.Matches = make([]string, tmp0)
	for tmp2 := range t.Matches {
		if t.Matches[tmp2], err = packets.ReadString(rr); err != nil {
			return err
		}
	}
	return
}
Example #9
0
func (t *UpdateScore) Decode(rr io.Reader) (err error) {
	if t.Name, err = packets.ReadString(rr); err != nil {
		return err
	}
	if err = binary.Read(rr, binary.BigEndian, t.Action); err != nil {
		return err
	}

	if t.ObjectiveName, err = packets.ReadString(rr); err != nil {
		return err
	}
	if t.Action != 1 {
		tmp0, err := packets.ReadVarint(rr)
		if err != nil {
			return err
		}
		t.Value = packets.VarInt(tmp0)

	}
	return
}
Example #10
0
func (t *TestPacket) Decode(rr io.Reader) (err error) {
	var tmp0 [1]byte
	if _, err = rr.Read(tmp0[:1]); err != nil {
		return err
	}
	t.b = tmp0[0] == 0x01

	if err = binary.Read(rr, binary.BigEndian, t.i8); err != nil {
		return err
	}

	if err = binary.Read(rr, binary.BigEndian, t.ui8); err != nil {
		return err
	}

	if err = binary.Read(rr, binary.BigEndian, t.i16); err != nil {
		return err
	}

	if err = binary.Read(rr, binary.BigEndian, t.ui16); err != nil {
		return err
	}

	if err = binary.Read(rr, binary.BigEndian, t.i32); err != nil {
		return err
	}

	if err = binary.Read(rr, binary.BigEndian, t.i64); err != nil {
		return err
	}

	if err = binary.Read(rr, binary.BigEndian, t.f32); err != nil {
		return err
	}

	if err = binary.Read(rr, binary.BigEndian, t.f64); err != nil {
		return err
	}

	tmp1, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	t.V32 = packets.VarInt(tmp1)

	tmp2, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	t.V64 = packets.VarLong(tmp2)

	if err = binary.Read(rr, binary.BigEndian, t.P); err != nil {
		return err
	}

	if err = binary.Read(rr, binary.BigEndian, t.A); err != nil {
		return err
	}

	if err = binary.Read(rr, binary.BigEndian, t.U); err != nil {
		return err
	}

	return
}
Example #11
0
func (t *Test) Decode(rr io.Reader) (err error) {
	if err = binary.Read(rr, binary.BigEndian, t.T.X); err != nil {
		return err
	}

	tmp0, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	tmp1 := make([]byte, tmp0)
	tmp2, err := rr.Read(tmp1)
	if err != nil {
		return err
	} else if int64(tmp2) != tmp0 {
		return errors.New("didn't read enough bytes for string")
	}
	t.T.Y = string(tmp1)

	tmp3, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	t.T.Z = packets.VarInt(tmp3)

	var tmp4 packets.VarInt
	tmp5, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	tmp4 = packets.VarInt(tmp5)

	if tmp4 < 0 {
		return fmt.Errorf("negative array size: %d < 0", tmp4)
	}
	t.TXs = make([]TX, tmp4)
	for tmp6 := range t.TXs {
		if err = binary.Read(rr, binary.BigEndian, t.TXs[tmp6].X); err != nil {
			return err
		}

		tmp7, err := packets.ReadVarint(rr)
		if err != nil {
			return err
		}
		tmp8 := make([]byte, tmp7)
		tmp9, err := rr.Read(tmp8)
		if err != nil {
			return err
		} else if int64(tmp9) != tmp7 {
			return errors.New("didn't read enough bytes for string")
		}
		t.TXs[tmp6].Y = string(tmp8)

		tmp10, err := packets.ReadVarint(rr)
		if err != nil {
			return err
		}
		t.TXs[tmp6].Z = packets.VarInt(tmp10)

	}
	return
}
Example #12
0
func (t *PlayerListItem) Decode(rr io.Reader) (err error) {
	tmp0, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	t.Action = packets.VarInt(tmp0)

	tmp1, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	t.NumPlayers = packets.VarInt(tmp1)

	var tmp2 packets.VarInt
	tmp3, err := packets.ReadVarint(rr)
	if err != nil {
		return err
	}
	tmp2 = packets.VarInt(tmp3)

	if tmp2 < 0 {
		return fmt.Errorf("negative array size: %d < 0", tmp2)
	}
	t.Players = make([]Player, tmp2)
	for tmp4 := range t.Players {
		if err = binary.Read(rr, binary.BigEndian, t.Players[tmp4].UUID); err != nil {
			return err
		}

		if t.Players[tmp4].Name, err = packets.ReadString(rr); err != nil {
			return err
		}
		var tmp5 packets.VarInt
		tmp6, err := packets.ReadVarint(rr)
		if err != nil {
			return err
		}
		tmp5 = packets.VarInt(tmp6)

		if tmp5 < 0 {
			return fmt.Errorf("negative array size: %d < 0", tmp5)
		}
		t.Players[tmp4].Properties = make([]Property, tmp5)
		for tmp7 := range t.Players[tmp4].Properties {
			if t.Players[tmp4].Properties[tmp7].Name, err = packets.ReadString(rr); err != nil {
				return err
			}
			if t.Players[tmp4].Properties[tmp7].Value, err = packets.ReadString(rr); err != nil {
				return err
			}
			if t.Players[tmp4].Properties[tmp7].Signed, err = packets.ReadBool(rr); err != nil {
				return err
			}
			if t.Players[tmp4].Properties[tmp7].Signed {
				if t.Players[tmp4].Properties[tmp7].Signature, err = packets.ReadString(rr); err != nil {
					return err
				}
			}
		}
		tmp8, err := packets.ReadVarint(rr)
		if err != nil {
			return err
		}
		t.Players[tmp4].Gamemode = packets.VarInt(tmp8)

		tmp9, err := packets.ReadVarint(rr)
		if err != nil {
			return err
		}
		t.Players[tmp4].Ping = packets.VarInt(tmp9)

		if t.Players[tmp4].HasDisplayName, err = packets.ReadBool(rr); err != nil {
			return err
		}
		if t.Players[tmp4].HasDisplayName {
			var tmp10 string
			if tmp10, err = packets.ReadString(rr); err != nil {
				return err
			}
			if err = json.Unmarshal([]byte(tmp10), &t.Players[tmp4].DisplayName); err != nil {
				return err
			}
		}
	}
	return
}