aboutsummaryrefslogtreecommitdiff
path: root/azalea-client
diff options
context:
space:
mode:
authorEightFactorial <29801334+EightFactorial@users.noreply.github.com>2023-03-11 14:00:10 -0800
committerGitHub <noreply@github.com>2023-03-11 16:00:10 -0600
commitc57c68ddf8cb9e4e8d27cf3e08f267a8a020c1c0 (patch)
tree3209e7c0f93f81c09d48fb13cd3a240c04aaa3b8 /azalea-client
parentf28efd5637cf3e129af018066421c090cb73ad50 (diff)
downloadazalea-drasl-c57c68ddf8cb9e4e8d27cf3e08f267a8a020c1c0.tar.xz
Add RegistryHolder struct and serde features (#81)
* Make RegistryHolder struct * Update deps * Move RegistryHolder to azalea-protocol * Convert bytes to bools and back * Rename and shuffle logic * Move logic into trait, rename methods * Final touchups * Ah, merge mistakes * Add serde support for ResourceLocation * Reuse structs * Error when serde skips values in debug mode Add missing attributes * Strict_registry feature, require packet feature * Add test * Move into packets * Docs and touchups * Reword docs * Move into module inside ClientboundLoginPacket * Add azalea-nbt serde feature * remove duplicate comment and type_ -> kind --------- Co-authored-by: mat <github@matdoes.dev>
Diffstat (limited to 'azalea-client')
-rw-r--r--azalea-client/src/packet_handling.rs59
1 files changed, 11 insertions, 48 deletions
diff --git a/azalea-client/src/packet_handling.rs b/azalea-client/src/packet_handling.rs
index 2f4f060a..ae38ec5a 100644
--- a/azalea-client/src/packet_handling.rs
+++ b/azalea-client/src/packet_handling.rs
@@ -199,58 +199,17 @@ fn process_packet_events(ecs: &mut World) {
query.get_mut(player_entity).unwrap();
{
- // TODO: have registry_holder be a struct because this sucks rn
- // best way would be to add serde support to azalea-nbt
-
- let registry_holder = p
+ let dimension = &p
.registry_holder
- .as_compound()
- .expect("Registry holder is not a compound")
- .get("")
- .expect("No \"\" tag")
- .as_compound()
- .expect("\"\" tag is not a compound");
- let dimension_types = registry_holder
- .get("minecraft:dimension_type")
- .expect("No dimension_type tag")
- .as_compound()
- .expect("dimension_type is not a compound")
- .get("value")
- .expect("No dimension_type value")
- .as_list()
- .expect("dimension_type value is not a list");
- let dimension_type = dimension_types
+ .root
+ .dimension_type
+ .value
.iter()
- .find(|t| {
- t.as_compound()
- .expect("dimension_type value is not a compound")
- .get("name")
- .expect("No name tag")
- .as_string()
- .expect("name is not a string")
- == p.dimension_type.to_string()
- })
+ .find(|t| t.name == p.dimension_type)
.unwrap_or_else(|| {
panic!("No dimension_type with name {}", p.dimension_type)
})
- .as_compound()
- .unwrap()
- .get("element")
- .expect("No element tag")
- .as_compound()
- .expect("element is not a compound");
- let height = (*dimension_type
- .get("height")
- .expect("No height tag")
- .as_int()
- .expect("height tag is not an int"))
- .try_into()
- .expect("height is not a u32");
- let min_y = *dimension_type
- .get("min_y")
- .expect("No min_y tag")
- .as_int()
- .expect("min_y tag is not an int");
+ .element;
let new_world_name = p.dimension.clone();
@@ -263,7 +222,11 @@ fn process_packet_events(ecs: &mut World) {
}
// add this world to the world_container (or don't if it's already
// there)
- let weak_world = world_container.insert(new_world_name.clone(), height, min_y);
+ let weak_world = world_container.insert(
+ new_world_name.clone(),
+ dimension.height,
+ dimension.min_y,
+ );
// set the partial_world to an empty world
// (when we add chunks or entities those will be in the
// world_container)