Exemplo n.º 1
0
func (t *Test) Encode(ww io.Writer) (err error) {
	if err = binary.Write(ww, binary.BigEndian, t.T.X); err != nil {
		return err
	}

	tmp0 := make([]byte, binary.MaxVarintLen32)
	tmp1 := []byte(t.T.Y)
	tmp2 := packets.PutVarint(tmp0, int64(len(tmp1)))
	if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp2]); err != nil {
		return err
	}
	if err = binary.Write(ww, binary.BigEndian, tmp1); err != nil {
		return err
	}

	tmp3 := make([]byte, binary.MaxVarintLen64)
	tmp4 := packets.PutVarint(tmp3, int64(t.T.Z))
	if err = binary.Write(ww, binary.BigEndian, tmp3[:tmp4]); err != nil {
		return err
	}

	tmp5 := make([]byte, binary.MaxVarintLen64)
	tmp6 := packets.PutVarint(tmp5, int64(len(t.TXs)))
	if err = binary.Write(ww, binary.BigEndian, tmp5[:tmp6]); err != nil {
		return err
	}

	for tmp7 := range t.TXs {
		if err = binary.Write(ww, binary.BigEndian, t.TXs[tmp7].X); err != nil {
			return err
		}

		tmp8 := make([]byte, binary.MaxVarintLen32)
		tmp9 := []byte(t.TXs[tmp7].Y)
		tmp10 := packets.PutVarint(tmp8, int64(len(tmp9)))
		if err = binary.Write(ww, binary.BigEndian, tmp8[:tmp10]); err != nil {
			return err
		}
		if err = binary.Write(ww, binary.BigEndian, tmp9); err != nil {
			return err
		}

		tmp11 := make([]byte, binary.MaxVarintLen64)
		tmp12 := packets.PutVarint(tmp11, int64(t.TXs[tmp7].Z))
		if err = binary.Write(ww, binary.BigEndian, tmp11[:tmp12]); err != nil {
			return err
		}

	}
	return
}
Exemplo n.º 2
0
func (t *X) Encode(ww io.Writer) (err error) {
	tmp0 := make([]byte, binary.MaxVarintLen64)
	tmp1 := packets.PutVarint(tmp0, int64(len(t.Ys)))
	if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
		return err
	}

	for tmp2 := range t.Ys {
		tmp3 := byte(0)
		if t.Ys[tmp2].A {
			tmp3 = byte(1)
		}
		if err = binary.Write(ww, binary.BigEndian, tmp3); err != nil {
			return err
		}

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

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

		}
	}
	return
}
Exemplo n.º 3
0
func (t *SetInitialCompression) Encode(ww io.Writer) (err error) {
	tmp0 := make([]byte, binary.MaxVarintLen64)
	tmp1 := packets.PutVarint(tmp0, int64(t.Threshold))
	if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
		return err
	}

	return
}
Exemplo n.º 4
0
func (t *ClientStatus) Encode(ww io.Writer) (err error) {
	tmp0 := make([]byte, binary.MaxVarintLen64)
	tmp1 := packets.PutVarint(tmp0, int64(t.ActionID))
	if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
		return err
	}

	return
}
Exemplo n.º 5
0
func (t *Teams) Encode(ww io.Writer) (err error) {
	if err = packets.WriteString(ww, t.Name); err != nil {
		return err
	}
	if err = binary.Write(ww, binary.BigEndian, t.Mode); err != nil {
		return err
	}

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

	}
	if t.Mode == 0 || t.Mode == 2 {
		if err = packets.WriteString(ww, t.NameTagVisibility); err != nil {
			return err
		}
	}
	if t.Mode == 0 || t.Mode == 2 {
		if err = binary.Write(ww, binary.BigEndian, t.Color); err != nil {
			return err
		}

	}
	if t.Mode == 0 || t.Mode == 3 || t.Mode == 4 {
		tmp0 := make([]byte, binary.MaxVarintLen64)
		tmp1 := packets.PutVarint(tmp0, int64(len(t.Players)))
		if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
			return err
		}

		for tmp2 := range t.Players {
			if err = packets.WriteString(ww, t.Players[tmp2]); err != nil {
				return err
			}
		}
	}
	return
}
Exemplo n.º 6
0
func (t *EncryptionResponse) Encode(ww io.Writer) (err error) {
	tmp0 := make([]byte, binary.MaxVarintLen64)
	tmp1 := packets.PutVarint(tmp0, int64(len(t.SharedSecret)))
	if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
		return err
	}

	if _, err = ww.Write(t.SharedSecret); err != nil {
		return err
	}
	tmp2 := make([]byte, binary.MaxVarintLen64)
	tmp3 := packets.PutVarint(tmp2, int64(len(t.VerifyToken)))
	if err = binary.Write(ww, binary.BigEndian, tmp2[:tmp3]); err != nil {
		return err
	}

	if _, err = ww.Write(t.VerifyToken); err != nil {
		return err
	}
	return
}
Exemplo n.º 7
0
func (t *Handshake) Encode(ww io.Writer) (err error) {
	tmp0 := make([]byte, binary.MaxVarintLen64)
	tmp1 := packets.PutVarint(tmp0, int64(t.ProtocolVersion))
	if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
		return err
	}

	if err = packets.WriteString(ww, t.Address); err != nil {
		return err
	}
	if err = binary.Write(ww, binary.BigEndian, t.Port); err != nil {
		return err
	}

	tmp2 := make([]byte, binary.MaxVarintLen64)
	tmp3 := packets.PutVarint(tmp2, int64(t.NextState))
	if err = binary.Write(ww, binary.BigEndian, tmp2[:tmp3]); err != nil {
		return err
	}

	return
}
Exemplo n.º 8
0
func (t *ServerTabComplete) Encode(ww io.Writer) (err error) {
	tmp0 := make([]byte, binary.MaxVarintLen64)
	tmp1 := packets.PutVarint(tmp0, int64(len(t.Matches)))
	if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
		return err
	}

	for tmp2 := range t.Matches {
		if err = packets.WriteString(ww, t.Matches[tmp2]); err != nil {
			return err
		}
	}
	return
}
Exemplo n.º 9
0
func (t *EncryptionRequest) Encode(ww io.Writer) (err error) {
	if err = packets.WriteString(ww, t.ServerID); err != nil {
		return err
	}
	tmp0 := make([]byte, binary.MaxVarintLen64)
	tmp1 := packets.PutVarint(tmp0, int64(len(t.PublicKey)))
	if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
		return err
	}

	if _, err = ww.Write(t.PublicKey); err != nil {
		return err
	}
	tmp2 := make([]byte, binary.MaxVarintLen64)
	tmp3 := packets.PutVarint(tmp2, int64(len(t.VerifyToken)))
	if err = binary.Write(ww, binary.BigEndian, tmp2[:tmp3]); err != nil {
		return err
	}

	if _, err = ww.Write(t.VerifyToken); err != nil {
		return err
	}
	return
}
Exemplo n.º 10
0
func (t *UpdateScore) Encode(ww io.Writer) (err error) {
	if err = packets.WriteString(ww, t.Name); err != nil {
		return err
	}
	if err = binary.Write(ww, binary.BigEndian, t.Action); err != nil {
		return err
	}

	if err = packets.WriteString(ww, t.ObjectiveName); err != nil {
		return err
	}
	if t.Action != 1 {
		tmp0 := make([]byte, binary.MaxVarintLen64)
		tmp1 := packets.PutVarint(tmp0, int64(t.Value))
		if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
			return err
		}

	}
	return
}
Exemplo n.º 11
0
func (t *TestPacket) Encode(ww io.Writer) (err error) {
	tmp0 := byte(0)
	if t.b {
		tmp0 = byte(1)
	}
	if err = binary.Write(ww, binary.BigEndian, tmp0); err != nil {
		return err
	}

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

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

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

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

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

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

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

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

	tmp1 := make([]byte, binary.MaxVarintLen64)
	tmp2 := packets.PutVarint(tmp1, int64(t.V32))
	if err = binary.Write(ww, binary.BigEndian, tmp1[:tmp2]); err != nil {
		return err
	}

	tmp3 := make([]byte, binary.MaxVarintLen64)
	tmp4 := packets.PutVarint(tmp3, int64(t.V64))
	if err = binary.Write(ww, binary.BigEndian, tmp3[:tmp4]); err != nil {
		return err
	}

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

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

	if err = binary.Write(ww, binary.BigEndian, t.U[:]); err != nil {
		return err
	}

	return
}
Exemplo n.º 12
0
func (t *PlayerListItem) Encode(ww io.Writer) (err error) {
	tmp0 := make([]byte, binary.MaxVarintLen64)
	tmp1 := packets.PutVarint(tmp0, int64(t.Action))
	if err = binary.Write(ww, binary.BigEndian, tmp0[:tmp1]); err != nil {
		return err
	}

	tmp2 := make([]byte, binary.MaxVarintLen64)
	tmp3 := packets.PutVarint(tmp2, int64(t.NumPlayers))
	if err = binary.Write(ww, binary.BigEndian, tmp2[:tmp3]); err != nil {
		return err
	}

	tmp4 := make([]byte, binary.MaxVarintLen64)
	tmp5 := packets.PutVarint(tmp4, int64(len(t.Players)))
	if err = binary.Write(ww, binary.BigEndian, tmp4[:tmp5]); err != nil {
		return err
	}

	for tmp6 := range t.Players {
		if err = binary.Write(ww, binary.BigEndian, t.Players[tmp6].UUID[:]); err != nil {
			return err
		}

		if err = packets.WriteString(ww, t.Players[tmp6].Name); err != nil {
			return err
		}
		tmp7 := make([]byte, binary.MaxVarintLen64)
		tmp8 := packets.PutVarint(tmp7, int64(len(t.Players[tmp6].Properties)))
		if err = binary.Write(ww, binary.BigEndian, tmp7[:tmp8]); err != nil {
			return err
		}

		for tmp9 := range t.Players[tmp6].Properties {
			if err = packets.WriteString(ww, t.Players[tmp6].Properties[tmp9].Name); err != nil {
				return err
			}
			if err = packets.WriteString(ww, t.Players[tmp6].Properties[tmp9].Value); err != nil {
				return err
			}
			if err = packets.WriteBool(ww, t.Players[tmp6].Properties[tmp9].Signed); err != nil {
				return err
			}
			if t.Players[tmp6].Properties[tmp9].Signed {
				if err = packets.WriteString(ww, t.Players[tmp6].Properties[tmp9].Signature); err != nil {
					return err
				}
			}
		}
		tmp10 := make([]byte, binary.MaxVarintLen64)
		tmp11 := packets.PutVarint(tmp10, int64(t.Players[tmp6].Gamemode))
		if err = binary.Write(ww, binary.BigEndian, tmp10[:tmp11]); err != nil {
			return err
		}

		tmp12 := make([]byte, binary.MaxVarintLen64)
		tmp13 := packets.PutVarint(tmp12, int64(t.Players[tmp6].Ping))
		if err = binary.Write(ww, binary.BigEndian, tmp12[:tmp13]); err != nil {
			return err
		}

		if err = packets.WriteBool(ww, t.Players[tmp6].HasDisplayName); err != nil {
			return err
		}
		if t.Players[tmp6].HasDisplayName {
			var tmp14 []byte
			if tmp14, err = json.Marshal(&t.Players[tmp6].DisplayName); err != nil {
				return err
			}
			if err = packets.WriteString(ww, string(tmp14)); err != nil {
				return err
			}
		}
	}
	return
}