func (this *packetClientJoinGameCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientJoinGame := new(PacketClientJoinGame)
	packetClientJoinGame.EntityId, err = packet.ReadInt32(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Gamemode, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Dimension, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Difficulty, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.MaxPlayers, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.LevelType, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.ReducedDebugInfo, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	decode = packetClientJoinGame
	return
}
func (this *PacketClientJoinGameCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientJoinGame := &PacketClientJoinGame{}
	packetClientJoinGame.EntityId, err = packet.ReadInt32(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Gamemode, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Dimension, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Difficulty, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.MaxPlayers, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.LevelType, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetClientJoinGame, nil
}
func (this *packetClientScoreboardObjectiveCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientScoreboardObjective := new(PacketClientScoreboardObjective)
	packetClientScoreboardObjective.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	switch packetClientScoreboardObjective.Action {
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_ADD:
		fallthrough
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_UPDATE:
		packetClientScoreboardObjective.Value, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientScoreboardObjective.Type, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_REMOVE:
		// no payload
	default:
		err = errors.New(fmt.Sprintf("Decode, PacketClientScoreboardObjective action is not valid: %d", packetClientScoreboardObjective.Action))
	}
	decode = packetClientScoreboardObjective
	return
}
func (this *packetClientTeamsCodec17) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientTeams := new(PacketClientTeams)
	packetClientTeams.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientTeams.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 2 {
		packetClientTeams.DisplayName, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Prefix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Suffix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.FriendlyFire, err = packet.ReadInt8(reader, util)
		if err != nil {
			return
		}
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 3 || packetClientTeams.Action == 4 {
		var playersLength uint16
		playersLength, err = packet.ReadUint16(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Players = make([]string, playersLength)
		var i uint16
		for i = 0; i < playersLength; i++ {
			packetClientTeams.Players[i], err = packet.ReadString(reader, util)
			if err != nil {
				return
			}
		}
	}
	decode = packetClientTeams
	return
}
Beispiel #5
0
func (this *PacketClientTeamsCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientTeams := &PacketClientTeams{}
	packetClientTeams.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientTeams.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 2 {
		packetClientTeams.DisplayName, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Prefix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Suffix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.FriendlyFire, err = packet.ReadInt8(reader, util)
		if err != nil {
			return
		}
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 3 || packetClientTeams.Action == 4 {
		var playersSize uint16
		playersSize, err = packet.ReadUint16(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Players = make([]string, playersSize)
		var i uint16
		for i = 0; i < playersSize; i++ {
			packetClientTeams.Players[i], err = packet.ReadString(reader, util)
			if err != nil {
				return
			}
		}
	}
	return packetClientTeams, nil
}
Beispiel #6
0
func (this *PacketClientRespawnCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientRespawn := &PacketClientRespawn{}
	packetClientRespawn.Dimension, err = packet.ReadInt32(reader, util)
	if err != nil {
		return
	}
	packetClientRespawn.Difficulty, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientRespawn.Gamemode, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientRespawn.LevelType, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetClientRespawn, nil
}
func (this *packetClientRespawnCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetClientRespawn := new(PacketClientRespawn)
	packetClientRespawn.Dimension, err = packet.ReadInt32(reader)
	if err != nil {
		return
	}
	packetClientRespawn.Difficulty, err = packet.ReadInt8(reader)
	if err != nil {
		return
	}
	packetClientRespawn.Gamemode, err = packet.ReadInt8(reader)
	if err != nil {
		return
	}
	packetClientRespawn.LevelType, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	decode = packetClientRespawn
	return
}
func (this *PacketClientScoreboardObjectiveCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientScoreboardObjective := &PacketClientScoreboardObjective{}
	packetClientScoreboardObjective.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Value, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	return packetClientScoreboardObjective, nil
}
func (this *packetClientScoreboardObjectiveCodec17) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetClientScoreboardObjective := new(PacketClientScoreboardObjective)
	packetClientScoreboardObjective.Name, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Value, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Action, err = packet.ReadInt8(reader)
	if err != nil {
		return
	}
	decode = packetClientScoreboardObjective
	return
}
func (this *packetClientTeamsCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientTeams := new(PacketClientTeams)
	packetClientTeams.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientTeams.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 2 {
		packetClientTeams.DisplayName, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Prefix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Suffix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.FriendlyFire, err = packet.ReadInt8(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.NameTagVisibility, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Color, err = packet.ReadInt8(reader, util)
		if err != nil {
			return
		}
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 3 || packetClientTeams.Action == 4 {
		var playersLength int
		playersLength, err = packet.ReadVarInt(reader, util)
		if err != nil {
			return
		}
		if playersLength < 0 {
			err = errors.New(fmt.Sprintf("Decode, Players length is below zero: %d", playersLength))
			return
		}
		if playersLength > 65535 {
			err = errors.New(fmt.Sprintf("Decode, Players length is above maximum: %d", playersLength))
			return
		}
		packetClientTeams.Players = make([]string, playersLength)
		for i := 0; i < playersLength; i++ {
			packetClientTeams.Players[i], err = packet.ReadString(reader, util)
			if err != nil {
				return
			}
		}
	}
	decode = packetClientTeams
	return
}