Skip to content

Commit

Permalink
1.18.2 protocol (758) (iceiix#706)
Browse files Browse the repository at this point in the history
Minor protocol update

https://minecraft.fandom.com/wiki/Java_Edition_1.18.2
https://wiki.vg/index.php?title=Protocol&oldid=17499 1.18.2 (758)
https://wiki.vg/index.php?title=Protocol&diff=17499&oldid=17341 1.18.1 (757) vs 1.18.2 (758)

* Add EntityRemoveEffect_VarInt, split i8 variant
* Add UpdateScore_VarInt, split u8 variant
* Add EntityEffect_VarInt, split i8 variant
  • Loading branch information
iceiix authored Aug 7, 2022
1 parent adb71c7 commit 069a391
Show file tree
Hide file tree
Showing 25 changed files with 280 additions and 68 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Discussion forum: [https://github.com/iceiix/stevenarella/discussions](https://g

| Game version | Protocol version | Supported? |
| ------ | --- | --- |
| 1.18.2 | 758 ||
| 1.18.1 | 757 ||
| 1.17.1 | 756 ||
| 1.16.5 | 754 ||
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ use std::io::{Read, Write};
use std::net::TcpStream;
use std::sync::atomic::{AtomicBool, AtomicI32, Ordering};

pub const SUPPORTED_PROTOCOLS: [i32; 26] = [
757, 756, 754, 753, 751, 736, 735, 578, 575, 498, 490, 485, 480, 477, 452, 451, 404, 340, 316,
315, 210, 109, 107, 74, 47, 5,
pub const SUPPORTED_PROTOCOLS: [i32; 27] = [
758, 757, 756, 754, 753, 751, 736, 735, 578, 575, 498, 490, 485, 480, 477, 452, 451, 404, 340,
316, 315, 210, 109, 107, 74, 47, 5,
];

static CURRENT_PROTOCOL_VERSION: AtomicI32 = AtomicI32::new(SUPPORTED_PROTOCOLS[0]);
Expand Down
27 changes: 22 additions & 5 deletions protocol/src/protocol/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,11 @@ state_packets!(
field entity_ids: LenPrefixed<u8, i32> =,
}
/// EntityRemoveEffect removes an effect from an entity.
packet EntityRemoveEffect {
packet EntityRemoveEffect_VarInt {
field entity_id: VarInt =,
field effect_id: VarInt =,
}
packet EntityRemoveEffect_i8 {
field entity_id: VarInt =,
field effect_id: i8 =,
}
Expand Down Expand Up @@ -2062,17 +2066,23 @@ state_packets!(
}
/// UpdateScore is used to update or remove an item from a scoreboard
/// objective.
packet UpdateScore {
packet UpdateScore_VarInt {
field name: String =,
field action: VarInt =,
field object_name: String =,
field value: Option<VarInt> = when(|p: &UpdateScore_VarInt| p.action.0 != 1),
}
packet UpdateScore_u8 {
field name: String =,
field action: u8 =,
field object_name: String =,
field value: Option<VarInt> = when(|p: &UpdateScore| p.action != 1),
field value: Option<VarInt> = when(|p: &UpdateScore_u8| p.action != 1),
}
packet UpdateScore_i32 {
field name: String =,
field action: u8 =,
field object_name: String =,
field value: Option<i32 > = when(|p: &UpdateScore_i32| p.action != 1),
field value: Option<i32> = when(|p: &UpdateScore_i32| p.action != 1),
}
/// UpdateSimulationDistance is used to set how far the client will process entities.
packet UpdateSimulationDistance {
Expand Down Expand Up @@ -2255,7 +2265,14 @@ state_packets!(
field properties: LenPrefixed<i32, packet::EntityProperty_i16> =,
}
/// EntityEffect applies a status effect to an entity for a given duration.
packet EntityEffect {
packet EntityEffect_VarInt {
field entity_id: VarInt =,
field effect_id: VarInt =,
field amplifier: i8 =,
field duration: VarInt =,
field hide_particles: bool =,
}
packet EntityEffect_i8 {
field entity_id: VarInt =,
field effect_id: i8 =,
field amplifier: i8 =,
Expand Down
3 changes: 3 additions & 0 deletions protocol/src/protocol/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod v1_16_1;
mod v1_16_4;
mod v1_17_1;
mod v1_18_1;
mod v1_18_2;
mod v1_7_10;
mod v1_8_9;
mod v1_9;
Expand All @@ -28,6 +29,7 @@ mod v1_9_2;
pub fn protocol_name_to_protocol_version(s: String) -> i32 {
match s.as_ref() {
"" => SUPPORTED_PROTOCOLS[0],
"1.18.2" => 758,
"1.18.1" => 757,
"1.17.1" => 756,
"1.16.5" => 754,
Expand Down Expand Up @@ -73,6 +75,7 @@ pub fn translate_internal_packet_id_for_version(
to_internal: bool,
) -> i32 {
match version {
758 => v1_18_2::translate_internal_packet_id(state, dir, id, to_internal),
757 => v1_18_1::translate_internal_packet_id(state, dir, id, to_internal),
756 => v1_17_1::translate_internal_packet_id(state, dir, id, to_internal),
754 | 753 | 751 => v1_16_4::translate_internal_packet_id(state, dir, id, to_internal),
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v15w39c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protocol_packet_ids!(
0x2e => TeleportPlayer_NoConfirm
0x2f => EntityUsedBed
0x30 => EntityDestroy
0x31 => EntityRemoveEffect
0x31 => EntityRemoveEffect_i8
0x32 => ResourcePackSend
0x33 => Respawn_Gamemode
0x34 => EntityHeadLook
Expand All @@ -102,7 +102,7 @@ protocol_packet_ids!(
0x3e => UpdateHealth
0x3f => ScoreboardObjective
0x40 => Teams_u8
0x41 => UpdateScore
0x41 => UpdateScore_u8
0x42 => SpawnPosition_NoAngle
0x43 => TimeUpdate
0x44 => Title_notext_component
Expand All @@ -111,7 +111,7 @@ protocol_packet_ids!(
0x47 => CollectItem_nocount
0x48 => EntityTeleport_i32
0x49 => EntityProperties_VarInt
0x4a => EntityEffect
0x4a => EntityEffect_i8
}
}
login Login {
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v18w50a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protocol_packet_ids!(
0x34 => EntityUsedBed
0x35 => UnlockRecipes_WithSmelting
0x36 => EntityDestroy
0x37 => EntityRemoveEffect
0x37 => EntityRemoveEffect_i8
0x38 => ResourcePackSend
0x39 => Respawn_Gamemode
0x3a => EntityHeadLook
Expand All @@ -126,7 +126,7 @@ protocol_packet_ids!(
0x46 => ScoreboardObjective
0x47 => SetPassengers
0x48 => Teams_u8
0x49 => UpdateScore
0x49 => UpdateScore_u8
0x4a => SpawnPosition_NoAngle
0x4b => TimeUpdate
0x4d => StopSound
Expand All @@ -137,7 +137,7 @@ protocol_packet_ids!(
0x52 => EntityTeleport_f64
0x53 => Advancements
0x54 => EntityProperties_VarInt
0x55 => EntityEffect
0x55 => EntityEffect_i8
0x56 => DeclareRecipes
0x57 => Tags_WithEntities
0x58 => UpdateLight_NoTrust
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v19w02a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protocol_packet_ids!(
0x34 => EntityUsedBed
0x35 => UnlockRecipes_WithSmelting
0x36 => EntityDestroy
0x37 => EntityRemoveEffect
0x37 => EntityRemoveEffect_i8
0x38 => ResourcePackSend
0x39 => Respawn_Gamemode
0x3a => EntityHeadLook
Expand All @@ -126,7 +126,7 @@ protocol_packet_ids!(
0x46 => ScoreboardObjective
0x47 => SetPassengers
0x48 => Teams_u8
0x49 => UpdateScore
0x49 => UpdateScore_u8
0x4a => SpawnPosition_NoAngle
0x4b => TimeUpdate
0x4d => StopSound
Expand All @@ -137,7 +137,7 @@ protocol_packet_ids!(
0x52 => EntityTeleport_f64
0x53 => Advancements
0x54 => EntityProperties_VarInt
0x55 => EntityEffect
0x55 => EntityEffect_i8
0x56 => DeclareRecipes
0x57 => Tags_WithEntities
0x58 => UpdateLight_NoTrust
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v1_10_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protocol_packet_ids!(
0x2e => TeleportPlayer_WithConfirm
0x2f => EntityUsedBed
0x30 => EntityDestroy
0x31 => EntityRemoveEffect
0x31 => EntityRemoveEffect_i8
0x32 => ResourcePackSend
0x33 => Respawn_Gamemode
0x34 => EntityHeadLook
Expand All @@ -106,7 +106,7 @@ protocol_packet_ids!(
0x3f => ScoreboardObjective
0x40 => SetPassengers
0x41 => Teams_u8
0x42 => UpdateScore
0x42 => UpdateScore_u8
0x43 => SpawnPosition_NoAngle
0x44 => TimeUpdate
0x45 => Title_notext
Expand All @@ -115,7 +115,7 @@ protocol_packet_ids!(
0x48 => CollectItem_nocount
0x49 => EntityTeleport_f64
0x4a => EntityProperties_VarInt
0x4b => EntityEffect
0x4b => EntityEffect_i8
}
}
login Login {
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v1_11_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protocol_packet_ids!(
0x2e => TeleportPlayer_WithConfirm
0x2f => EntityUsedBed
0x30 => EntityDestroy
0x31 => EntityRemoveEffect
0x31 => EntityRemoveEffect_i8
0x32 => ResourcePackSend
0x33 => Respawn_Gamemode
0x34 => EntityHeadLook
Expand All @@ -106,7 +106,7 @@ protocol_packet_ids!(
0x3f => ScoreboardObjective
0x40 => SetPassengers
0x41 => Teams_u8
0x42 => UpdateScore
0x42 => UpdateScore_u8
0x43 => SpawnPosition_NoAngle
0x44 => TimeUpdate
0x45 => Title
Expand All @@ -115,7 +115,7 @@ protocol_packet_ids!(
0x48 => CollectItem
0x49 => EntityTeleport_f64
0x4a => EntityProperties_VarInt
0x4b => EntityEffect
0x4b => EntityEffect_i8
}
}
login Login {
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v1_12_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protocol_packet_ids!(
0x30 => EntityUsedBed
0x31 => UnlockRecipes_NoSmelting
0x32 => EntityDestroy
0x33 => EntityRemoveEffect
0x33 => EntityRemoveEffect_i8
0x34 => ResourcePackSend
0x35 => Respawn_Gamemode
0x36 => EntityHeadLook
Expand All @@ -112,7 +112,7 @@ protocol_packet_ids!(
0x42 => ScoreboardObjective
0x43 => SetPassengers
0x44 => Teams_u8
0x45 => UpdateScore
0x45 => UpdateScore_u8
0x46 => SpawnPosition_NoAngle
0x47 => TimeUpdate
0x48 => Title
Expand All @@ -122,7 +122,7 @@ protocol_packet_ids!(
0x4c => EntityTeleport_f64
0x4d => Advancements
0x4e => EntityProperties_VarInt
0x4f => EntityEffect
0x4f => EntityEffect_i8
}
}
login Login {
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v1_13_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protocol_packet_ids!(
0x33 => EntityUsedBed
0x34 => UnlockRecipes_WithSmelting
0x35 => EntityDestroy
0x36 => EntityRemoveEffect
0x36 => EntityRemoveEffect_i8
0x37 => ResourcePackSend
0x38 => Respawn_Gamemode
0x39 => EntityHeadLook
Expand All @@ -125,7 +125,7 @@ protocol_packet_ids!(
0x45 => ScoreboardObjective
0x46 => SetPassengers
0x47 => Teams_VarInt
0x48 => UpdateScore
0x48 => UpdateScore_u8
0x49 => SpawnPosition_NoAngle
0x4a => TimeUpdate
0x4c => StopSound
Expand All @@ -135,7 +135,7 @@ protocol_packet_ids!(
0x50 => EntityTeleport_f64
0x51 => Advancements
0x52 => EntityProperties_VarInt
0x53 => EntityEffect
0x53 => EntityEffect_i8
0x54 => DeclareRecipes
0x55 => Tags
}
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v1_14.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protocol_packet_ids!(
0x35 => TeleportPlayer_WithConfirm
0x36 => UnlockRecipes_WithSmelting
0x37 => EntityDestroy
0x38 => EntityRemoveEffect
0x38 => EntityRemoveEffect_i8
0x39 => ResourcePackSend
0x3a => Respawn_Gamemode
0x3b => EntityHeadLook
Expand All @@ -132,7 +132,7 @@ protocol_packet_ids!(
0x49 => ScoreboardObjective
0x4a => SetPassengers
0x4b => Teams_VarInt
0x4c => UpdateScore
0x4c => UpdateScore_u8
0x4d => SpawnPosition_NoAngle
0x4e => TimeUpdate
0x4f => Title
Expand All @@ -145,7 +145,7 @@ protocol_packet_ids!(
0x56 => EntityTeleport_f64
0x57 => Advancements
0x58 => EntityProperties_VarInt
0x59 => EntityEffect
0x59 => EntityEffect_i8
0x5a => DeclareRecipes
0x5b => Tags_WithEntities
}
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v1_14_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protocol_packet_ids!(
0x35 => TeleportPlayer_WithConfirm
0x36 => UnlockRecipes_WithSmelting
0x37 => EntityDestroy
0x38 => EntityRemoveEffect
0x38 => EntityRemoveEffect_i8
0x39 => ResourcePackSend
0x3a => Respawn_Gamemode
0x3b => EntityHeadLook
Expand All @@ -132,7 +132,7 @@ protocol_packet_ids!(
0x49 => ScoreboardObjective
0x4a => SetPassengers
0x4b => Teams_VarInt
0x4c => UpdateScore
0x4c => UpdateScore_u8
0x4d => SpawnPosition_NoAngle
0x4e => TimeUpdate
0x4f => Title
Expand All @@ -145,7 +145,7 @@ protocol_packet_ids!(
0x56 => EntityTeleport_f64
0x57 => Advancements
0x58 => EntityProperties_VarInt
0x59 => EntityEffect
0x59 => EntityEffect_i8
0x5a => DeclareRecipes
0x5b => Tags_WithEntities
}
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v1_14_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protocol_packet_ids!(
0x35 => TeleportPlayer_WithConfirm
0x36 => UnlockRecipes_WithSmelting
0x37 => EntityDestroy
0x38 => EntityRemoveEffect
0x38 => EntityRemoveEffect_i8
0x39 => ResourcePackSend
0x3a => Respawn_Gamemode
0x3b => EntityHeadLook
Expand All @@ -132,7 +132,7 @@ protocol_packet_ids!(
0x49 => ScoreboardObjective
0x4a => SetPassengers
0x4b => Teams_VarInt
0x4c => UpdateScore
0x4c => UpdateScore_u8
0x4d => SpawnPosition_NoAngle
0x4e => TimeUpdate
0x4f => Title
Expand All @@ -145,7 +145,7 @@ protocol_packet_ids!(
0x56 => EntityTeleport_f64
0x57 => Advancements
0x58 => EntityProperties_VarInt
0x59 => EntityEffect
0x59 => EntityEffect_i8
0x5a => DeclareRecipes
0x5b => Tags_WithEntities
}
Expand Down
6 changes: 3 additions & 3 deletions protocol/src/protocol/versions/v1_14_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protocol_packet_ids!(
0x35 => TeleportPlayer_WithConfirm
0x36 => UnlockRecipes_WithSmelting
0x37 => EntityDestroy
0x38 => EntityRemoveEffect
0x38 => EntityRemoveEffect_i8
0x39 => ResourcePackSend
0x3a => Respawn_Gamemode
0x3b => EntityHeadLook
Expand All @@ -132,7 +132,7 @@ protocol_packet_ids!(
0x49 => ScoreboardObjective
0x4a => SetPassengers
0x4b => Teams_VarInt
0x4c => UpdateScore
0x4c => UpdateScore_u8
0x4d => SpawnPosition_NoAngle
0x4e => TimeUpdate
0x4f => Title
Expand All @@ -145,7 +145,7 @@ protocol_packet_ids!(
0x56 => EntityTeleport_f64
0x57 => Advancements
0x58 => EntityProperties_VarInt
0x59 => EntityEffect
0x59 => EntityEffect_i8
0x5a => DeclareRecipes
0x5b => Tags_WithEntities
}
Expand Down
Loading

0 comments on commit 069a391

Please sign in to comment.