示例#1
0
func (t *LoginSuccess) Decode(rr io.Reader) (err error) {
	if t.UUID, err = packets.ReadString(rr); err != nil {
		return err
	}
	if t.Username, err = packets.ReadString(rr); err != nil {
		return err
	}
	return
}
示例#2
0
func (t *JoinGame) Decode(rr io.Reader) (err error) {
	if err = binary.Read(rr, binary.BigEndian, t.EntityID); err != nil {
		return err
	}

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

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

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

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

	if t.LevelType, err = packets.ReadString(rr); err != nil {
		return err
	}
	if t.ReducedDebug, err = packets.ReadBool(rr); err != nil {
		return err
	}
	return
}
示例#3
0
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
}
示例#4
0
func (t *ClientPluginMessage) Decode(rr io.Reader) (err error) {
	if t.Channel, err = packets.ReadString(rr); err != nil {
		return err
	}
	if t.Data, err = ioutil.ReadAll(rr); err != nil {
		return
	}
	return
}
示例#5
0
func (t *LoginDisconnect) Decode(rr io.Reader) (err error) {
	var tmp0 string
	if tmp0, err = packets.ReadString(rr); err != nil {
		return err
	}
	if err = json.Unmarshal([]byte(tmp0), &t.Reason); err != nil {
		return err
	}
	return
}
func (t *StatusResponse) Decode(rr io.Reader) (err error) {
	var tmp0 string
	if tmp0, err = packets.ReadString(rr); err != nil {
		return err
	}
	if err = json.Unmarshal([]byte(tmp0), &t.Status); err != nil {
		return err
	}
	return
}
示例#7
0
func (t *ShowScoreboard) Decode(rr io.Reader) (err error) {
	if err = binary.Read(rr, binary.BigEndian, t.Position); err != nil {
		return err
	}

	if t.Name, err = packets.ReadString(rr); err != nil {
		return err
	}
	return
}
示例#8
0
func (t *ScoreboardObjective) 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.Value, err = packets.ReadString(rr); err != nil {
			return err
		}
	}
	if t.Mode == 0 || t.Mode == 2 {
		if t.Type, err = packets.ReadString(rr); err != nil {
			return err
		}
	}
	return
}
示例#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
}
示例#10
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
}
示例#11
0
func (t *ServerMessage) Decode(rr io.Reader) (err error) {
	var tmp0 string
	if tmp0, err = packets.ReadString(rr); err != nil {
		return err
	}
	if err = json.Unmarshal([]byte(tmp0), &t.Data); err != nil {
		return err
	}
	if err = binary.Read(rr, binary.BigEndian, t.Position); err != nil {
		return err
	}

	return
}
示例#12
0
func (t *ClientTabComplete) Decode(rr io.Reader) (err error) {
	if t.Text, err = packets.ReadString(rr); err != nil {
		return err
	}
	if t.HasPosition, err = packets.ReadBool(rr); err != nil {
		return err
	}
	if t.HasPosition {
		if err = binary.Read(rr, binary.BigEndian, t.LookedAtBlock); err != nil {
			return err
		}

	}
	return
}
示例#13
0
func (t *Respawn) Decode(rr io.Reader) (err error) {
	if err = binary.Read(rr, binary.BigEndian, t.Dimension); err != nil {
		return err
	}

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

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

	if t.LevelType, err = packets.ReadString(rr); err != nil {
		return err
	}
	return
}
示例#14
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
}
示例#15
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
}
示例#16
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
}
示例#17
0
func (t *ClientMessage) Decode(rr io.Reader) (err error) {
	if t.Message, err = packets.ReadString(rr); err != nil {
		return err
	}
	return
}