1.13+: Fix parsing Teams packet. Closes #205 (#208)

* Add Teams_VarInt packet variant for 1.13+

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150#Teams

* Rename the variant for 1.9-1.12.2 to Teams_u8
This commit is contained in:
iceiix 2019-08-11 17:46:34 -07:00 committed by GitHub
parent 45099165d9
commit d1f88c9797
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 37 additions and 24 deletions

View File

@ -1529,17 +1529,30 @@ state_packets!(
field passengers: LenPrefixed<VarInt, VarInt> =, field passengers: LenPrefixed<VarInt, VarInt> =,
} }
/// Teams creates and updates teams /// Teams creates and updates teams
packet Teams { packet Teams_VarInt {
field name: String =, field name: String =,
field mode: u8 =, field mode: u8 =,
field display_name: Option<String> = when(|p: &Teams| p.mode == 0 || p.mode == 2), field display_name: Option<String> = when(|p: &Teams_VarInt| p.mode == 0 || p.mode == 2),
field prefix: Option<String> = when(|p: &Teams| p.mode == 0 || p.mode == 2), field flags: Option<u8> = when(|p: &Teams_VarInt| p.mode == 0 || p.mode == 2),
field suffix: Option<String> = when(|p: &Teams| p.mode == 0 || p.mode == 2), field name_tag_visibility: Option<String> = when(|p: &Teams_VarInt| p.mode == 0 || p.mode == 2),
field flags: Option<u8> = when(|p: &Teams| p.mode == 0 || p.mode == 2), field collision_rule: Option<String> = when(|p: &Teams_VarInt| p.mode == 0 || p.mode == 2),
field name_tag_visibility: Option<String> = when(|p: &Teams| p.mode == 0 || p.mode == 2), field formatting: Option<VarInt> = when(|p: &Teams_VarInt| p.mode == 0 || p.mode == 2),
field collision_rule: Option<String> = when(|p: &Teams| p.mode == 0 || p.mode == 2), field prefix: Option<String> = when(|p: &Teams_VarInt| p.mode == 0 || p.mode == 2),
field color: Option<i8> = when(|p: &Teams| p.mode == 0 || p.mode == 2), field suffix: Option<String> = when(|p: &Teams_VarInt| p.mode == 0 || p.mode == 2),
field players: Option<LenPrefixed<VarInt, String>> = when(|p: &Teams| p.mode == 0 || p.mode == 3 || p.mode == 4), field players: Option<LenPrefixed<VarInt, String>> = when(|p: &Teams_VarInt| p.mode == 0 || p.mode == 3 || p.mode == 4),
}
packet Teams_u8 {
field name: String =,
field mode: u8 =,
field data: Vec<u8> =,
field display_name: Option<String> = when(|p: &Teams_u8| p.mode == 0 || p.mode == 2),
field prefix: Option<String> = when(|p: &Teams_u8| p.mode == 0 || p.mode == 2),
field suffix: Option<String> = when(|p: &Teams_u8| p.mode == 0 || p.mode == 2),
field flags: Option<u8> = when(|p: &Teams_u8| p.mode == 0 || p.mode == 2),
field name_tag_visibility: Option<String> = when(|p: &Teams_u8| p.mode == 0 || p.mode == 2),
field collision_rule: Option<String> = when(|p: &Teams_u8| p.mode == 0 || p.mode == 2),
field color: Option<i8> = when(|p: &Teams_u8| p.mode == 0 || p.mode == 2),
field players: Option<LenPrefixed<VarInt, String>> = when(|p: &Teams_u8| p.mode == 0 || p.mode == 3 || p.mode == 4),
} }
packet Teams_NoVisColor { packet Teams_NoVisColor {
field name: String =, field name: String =,

View File

@ -101,7 +101,7 @@ protocol_packet_ids!(
0x3d => SetExperience 0x3d => SetExperience
0x3e => UpdateHealth 0x3e => UpdateHealth
0x3f => ScoreboardObjective 0x3f => ScoreboardObjective
0x40 => Teams 0x40 => Teams_u8
0x41 => UpdateScore 0x41 => UpdateScore
0x42 => SpawnPosition 0x42 => SpawnPosition
0x43 => TimeUpdate 0x43 => TimeUpdate

View File

@ -125,7 +125,7 @@ protocol_packet_ids!(
0x45 => UpdateHealth 0x45 => UpdateHealth
0x46 => ScoreboardObjective 0x46 => ScoreboardObjective
0x47 => SetPassengers 0x47 => SetPassengers
0x48 => Teams 0x48 => Teams_u8
0x49 => UpdateScore 0x49 => UpdateScore
0x4a => SpawnPosition 0x4a => SpawnPosition
0x4b => TimeUpdate 0x4b => TimeUpdate

View File

@ -125,7 +125,7 @@ protocol_packet_ids!(
0x45 => UpdateHealth 0x45 => UpdateHealth
0x46 => ScoreboardObjective 0x46 => ScoreboardObjective
0x47 => SetPassengers 0x47 => SetPassengers
0x48 => Teams 0x48 => Teams_u8
0x49 => UpdateScore 0x49 => UpdateScore
0x4a => SpawnPosition 0x4a => SpawnPosition
0x4b => TimeUpdate 0x4b => TimeUpdate

View File

@ -105,7 +105,7 @@ protocol_packet_ids!(
0x3e => UpdateHealth 0x3e => UpdateHealth
0x3f => ScoreboardObjective 0x3f => ScoreboardObjective
0x40 => SetPassengers 0x40 => SetPassengers
0x41 => Teams 0x41 => Teams_u8
0x42 => UpdateScore 0x42 => UpdateScore
0x43 => SpawnPosition 0x43 => SpawnPosition
0x44 => TimeUpdate 0x44 => TimeUpdate

View File

@ -105,7 +105,7 @@ protocol_packet_ids!(
0x3e => UpdateHealth 0x3e => UpdateHealth
0x3f => ScoreboardObjective 0x3f => ScoreboardObjective
0x40 => SetPassengers 0x40 => SetPassengers
0x41 => Teams 0x41 => Teams_u8
0x42 => UpdateScore 0x42 => UpdateScore
0x43 => SpawnPosition 0x43 => SpawnPosition
0x44 => TimeUpdate 0x44 => TimeUpdate

View File

@ -111,7 +111,7 @@ protocol_packet_ids!(
0x41 => UpdateHealth 0x41 => UpdateHealth
0x42 => ScoreboardObjective 0x42 => ScoreboardObjective
0x43 => SetPassengers 0x43 => SetPassengers
0x44 => Teams 0x44 => Teams_u8
0x45 => UpdateScore 0x45 => UpdateScore
0x46 => SpawnPosition 0x46 => SpawnPosition
0x47 => TimeUpdate 0x47 => TimeUpdate

View File

@ -124,7 +124,7 @@ protocol_packet_ids!(
0x44 => UpdateHealth 0x44 => UpdateHealth
0x45 => ScoreboardObjective 0x45 => ScoreboardObjective
0x46 => SetPassengers 0x46 => SetPassengers
0x47 => Teams 0x47 => Teams_VarInt
0x48 => UpdateScore 0x48 => UpdateScore
0x49 => SpawnPosition 0x49 => SpawnPosition
0x4a => TimeUpdate 0x4a => TimeUpdate

View File

@ -131,7 +131,7 @@ protocol_packet_ids!(
0x48 => UpdateHealth 0x48 => UpdateHealth
0x49 => ScoreboardObjective 0x49 => ScoreboardObjective
0x4a => SetPassengers 0x4a => SetPassengers
0x4b => Teams 0x4b => Teams_VarInt
0x4c => UpdateScore 0x4c => UpdateScore
0x4d => SpawnPosition 0x4d => SpawnPosition
0x4e => TimeUpdate 0x4e => TimeUpdate

View File

@ -131,7 +131,7 @@ protocol_packet_ids!(
0x48 => UpdateHealth 0x48 => UpdateHealth
0x49 => ScoreboardObjective 0x49 => ScoreboardObjective
0x4a => SetPassengers 0x4a => SetPassengers
0x4b => Teams 0x4b => Teams_VarInt
0x4c => UpdateScore 0x4c => UpdateScore
0x4d => SpawnPosition 0x4d => SpawnPosition
0x4e => TimeUpdate 0x4e => TimeUpdate

View File

@ -131,7 +131,7 @@ protocol_packet_ids!(
0x48 => UpdateHealth 0x48 => UpdateHealth
0x49 => ScoreboardObjective 0x49 => ScoreboardObjective
0x4a => SetPassengers 0x4a => SetPassengers
0x4b => Teams 0x4b => Teams_VarInt
0x4c => UpdateScore 0x4c => UpdateScore
0x4d => SpawnPosition 0x4d => SpawnPosition
0x4e => TimeUpdate 0x4e => TimeUpdate

View File

@ -131,7 +131,7 @@ protocol_packet_ids!(
0x48 => UpdateHealth 0x48 => UpdateHealth
0x49 => ScoreboardObjective 0x49 => ScoreboardObjective
0x4a => SetPassengers 0x4a => SetPassengers
0x4b => Teams 0x4b => Teams_VarInt
0x4c => UpdateScore 0x4c => UpdateScore
0x4d => SpawnPosition 0x4d => SpawnPosition
0x4e => TimeUpdate 0x4e => TimeUpdate

View File

@ -131,7 +131,7 @@ protocol_packet_ids!(
0x48 => UpdateHealth 0x48 => UpdateHealth
0x49 => ScoreboardObjective 0x49 => ScoreboardObjective
0x4a => SetPassengers 0x4a => SetPassengers
0x4b => Teams 0x4b => Teams_VarInt
0x4c => UpdateScore 0x4c => UpdateScore
0x4d => SpawnPosition 0x4d => SpawnPosition
0x4e => TimeUpdate 0x4e => TimeUpdate

View File

@ -98,7 +98,7 @@ protocol_packet_ids!(
0x3b => ScoreboardObjective 0x3b => ScoreboardObjective
0x3c => UpdateScore 0x3c => UpdateScore
0x3d => ScoreboardDisplay 0x3d => ScoreboardDisplay
0x3e => Teams 0x3e => Teams_u8
0x3f => PluginMessageClientbound 0x3f => PluginMessageClientbound
0x40 => Disconnect 0x40 => Disconnect
0x41 => ServerDifficulty 0x41 => ServerDifficulty

View File

@ -105,7 +105,7 @@ protocol_packet_ids!(
0x3e => UpdateHealth 0x3e => UpdateHealth
0x3f => ScoreboardObjective 0x3f => ScoreboardObjective
0x40 => SetPassengers 0x40 => SetPassengers
0x41 => Teams 0x41 => Teams_u8
0x42 => UpdateScore 0x42 => UpdateScore
0x43 => SpawnPosition 0x43 => SpawnPosition
0x44 => TimeUpdate 0x44 => TimeUpdate

View File

@ -105,7 +105,7 @@ protocol_packet_ids!(
0x3e => UpdateHealth 0x3e => UpdateHealth
0x3f => ScoreboardObjective 0x3f => ScoreboardObjective
0x40 => SetPassengers 0x40 => SetPassengers
0x41 => Teams 0x41 => Teams_u8
0x42 => UpdateScore 0x42 => UpdateScore
0x43 => SpawnPosition 0x43 => SpawnPosition
0x44 => TimeUpdate 0x44 => TimeUpdate