diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2023-09-21 11:16:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-21 11:16:29 -0500 |
| commit | 7b3e2e4bf793466a351510c7fbbd08234e93bb0e (patch) | |
| tree | 7177a919de9982d9e3c7f36a76d2025696f465b6 /azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs | |
| parent | 83cce236145cdab1872a472a70943b669a880965 (diff) | |
| download | azalea-drasl-7b3e2e4bf793466a351510c7fbbd08234e93bb0e.tar.xz | |
1.20.2 (#99)
* add configuration state
* start updating to 23w31a
* implement a bit more of 23w31a
* chunk batching
* start adding configuration state
* ioasfhjgsd
* almost works
* configuration state mostly implemented
* handle other packets in configuration state and fix keepalive
* cleanup, fix warnings
* 23w32a
* fix some doctests
* 23w33a
* 23w35a
* 1.20.2-pre2
* fix system conflicts
* 1.20.2-pre4
* make tests compile
* tests pass
* 1.20.2-rc2
* 1.20.2
* Revert "1.20.2"
This reverts commit dd152fd265332ead333c919e585ded6d609d7468.
* didn't mean to commit that code
---------
Co-authored-by: mat <git@matdoes.dev>
Diffstat (limited to 'azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs')
| -rwxr-xr-x | azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs index 81704b37..5a792849 100755 --- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs @@ -9,7 +9,7 @@ use std::io::Cursor; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundUpdateAdvancementsPacket { pub reset: bool, - pub added: HashMap<ResourceLocation, Advancement>, + pub added: Vec<AdvancementHolder>, pub removed: Vec<ResourceLocation>, pub progress: HashMap<ResourceLocation, AdvancementProgress>, } @@ -18,7 +18,6 @@ pub struct ClientboundUpdateAdvancementsPacket { pub struct Advancement { pub parent_id: Option<ResourceLocation>, pub display: Option<DisplayInfo>, - pub criteria: HashMap<ResourceLocation, Criterion>, pub requirements: Vec<Vec<String>>, pub sends_telemetry_event: bool, } @@ -103,15 +102,17 @@ pub enum FrameType { Goal = 2, } -// nothing is written here -#[derive(Clone, Debug, McBuf)] -pub struct Criterion {} - -pub type AdvancementProgress = HashMap<ResourceLocation, CriterionProgress>; +pub type AdvancementProgress = HashMap<String, CriterionProgress>; #[derive(Clone, Debug, McBuf)] pub struct CriterionProgress { - date: Option<u64>, + pub date: Option<u64>, +} + +#[derive(Clone, Debug, McBuf)] +pub struct AdvancementHolder { + pub id: ResourceLocation, + pub value: Advancement, } #[cfg(test)] @@ -125,9 +126,9 @@ mod tests { fn test() { let packet = ClientboundUpdateAdvancementsPacket { reset: true, - added: [( - ResourceLocation::new("minecraft:test"), - Advancement { + added: [AdvancementHolder { + id: ResourceLocation::new("minecraft:test"), + value: Advancement { parent_id: None, display: Some(DisplayInfo { title: FormattedText::from("title".to_string()), @@ -140,18 +141,17 @@ mod tests { x: 0.0, y: 0.0, }), - criteria: HashMap::new(), requirements: Vec::new(), sends_telemetry_event: false, }, - )] + }] .into_iter() .collect(), removed: vec![ResourceLocation::new("minecraft:test2")], progress: [( ResourceLocation::new("minecraft:test3"), [( - ResourceLocation::new("minecraft:test4"), + "minecraft:test4".to_string(), CriterionProgress { date: Some(123456789), }, @@ -173,12 +173,26 @@ mod tests { let advancement = packet .added - .get(&ResourceLocation::new("minecraft:test")) + .into_iter() + .find_map(|a| { + if a.id == ResourceLocation::new("minecraft:test") { + Some(a.value) + } else { + None + } + }) .unwrap() .clone(); let read_advancement = read_packet .added - .get(&ResourceLocation::new("minecraft:test")) + .into_iter() + .find_map(|a| { + if a.id == ResourceLocation::new("minecraft:test") { + Some(a.value) + } else { + None + } + }) .unwrap() .clone(); assert_eq!(advancement.parent_id, read_advancement.parent_id); |
