1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

fix errors when switching worlds

This commit is contained in:
mat 2025-01-21 23:53:11 +00:00
parent 900a4234e5
commit 53fca5faf4
7 changed files with 23 additions and 20 deletions

View file

@ -111,7 +111,10 @@ pub fn handle_receive_chunk_events(
heightmaps, heightmaps,
&mut instance.chunks, &mut instance.chunks,
) { ) {
error!("Couldn't set chunk data: {e}"); error!(
"Couldn't set chunk data: {e}. World height: {}",
instance.chunks.height
);
} }
} }
} }

View file

@ -253,13 +253,12 @@ pub fn process_packet_events(ecs: &mut World) {
continue; continue;
}; };
let dimension_type = let dimension_name = ResourceLocation::new(&p.common.dimension.to_string());
ResourceLocation::new(&p.common.dimension_type.to_string());
let dimension = dimension_type_element let Some(dimension) = dimension_type_element.map.get(&dimension_name) else {
.map error!("No dimension_type with name {dimension_name}")
.get(&dimension_type) continue;
.unwrap_or_else(|| panic!("No dimension_type with name {dimension_type}")); };
// add this world to the instance_container (or don't if it's already // add this world to the instance_container (or don't if it's already
// there) // there)
@ -1394,17 +1393,16 @@ pub fn process_packet_events(ecs: &mut World) {
let Some(dimension_type_element) = let Some(dimension_type_element) =
instance_holder.instance.read().registries.dimension_type() instance_holder.instance.read().registries.dimension_type()
else { else {
error!("Server didn't send dimension type registry, can't log in"); error!("Server didn't send dimension type registry, can't log in.");
continue; continue;
}; };
let dimension_type = let dimension_name = ResourceLocation::new(&p.common.dimension.to_string());
ResourceLocation::new(&p.common.dimension_type.to_string());
let dimension = dimension_type_element let Some(dimension) = dimension_type_element.map.get(&dimension_name) else {
.map error!("No dimension_type with name {dimension_name}");
.get(&dimension_type) continue;
.unwrap_or_else(|| panic!("No dimension_type with name {dimension_type}")); };
// add this world to the instance_container (or don't if it's already // add this world to the instance_container (or don't if it's already
// there) // there)

View file

@ -152,7 +152,7 @@ pub struct DimensionTypeElement {
pub natural: bool, pub natural: bool,
pub piglin_safe: bool, pub piglin_safe: bool,
pub respawn_anchor_works: bool, pub respawn_anchor_works: bool,
pub ultrawarm: bool, pub ultrawarm: Option<bool>,
} }
/// Dimension attributes. /// Dimension attributes.
@ -161,7 +161,7 @@ pub struct DimensionTypeElement {
pub struct DimensionTypeElement { pub struct DimensionTypeElement {
pub height: u32, pub height: u32,
pub min_y: i32, pub min_y: i32,
pub ultrawarm: bool, pub ultrawarm: Option<bool>,
#[simdnbt(flatten)] #[simdnbt(flatten)]
pub _extra: HashMap<String, NbtTag>, pub _extra: HashMap<String, NbtTag>,
} }

View file

@ -35,7 +35,7 @@ pub fn update_in_water_state_and_do_fluid_pushing(
.registries .registries
.dimension_type() .dimension_type()
.and_then(|d| d.map.get(instance_name).map(|d| d.ultrawarm)) .and_then(|d| d.map.get(instance_name).map(|d| d.ultrawarm))
== Some(true); == Some(Some(true));
let lava_push_factor = if is_ultrawarm { let lava_push_factor = if is_ultrawarm {
0.007 0.007
} else { } else {

View file

@ -7,7 +7,7 @@ use azalea_core::{
#[derive(Clone, Debug, AzBuf)] #[derive(Clone, Debug, AzBuf)]
pub struct CommonPlayerSpawnInfo { pub struct CommonPlayerSpawnInfo {
pub dimension_type: azalea_registry::DimensionType, pub dimension: azalea_registry::DimensionType,
pub dimension: ResourceLocation, pub dimension: ResourceLocation,
pub seed: i64, pub seed: i64,
pub game_type: GameMode, pub game_type: GameMode,

View file

@ -9,7 +9,7 @@ use derive_more::{Deref, DerefMut};
use nohash_hasher::IntMap; use nohash_hasher::IntMap;
use parking_lot::RwLock; use parking_lot::RwLock;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use tracing::error; use tracing::{debug, error};
use crate::{ChunkStorage, Instance}; use crate::{ChunkStorage, Instance};
@ -43,7 +43,7 @@ impl InstanceContainer {
self.instances.get(name).and_then(|world| world.upgrade()) self.instances.get(name).and_then(|world| world.upgrade())
} }
/// Add an empty world to the container (or not if it already exists) and /// Add an empty world to the container (unless it already exists) and
/// returns a strong reference to the world. /// returns a strong reference to the world.
#[must_use = "the world will be immediately forgotten if unused"] #[must_use = "the world will be immediately forgotten if unused"]
pub fn insert( pub fn insert(
@ -74,6 +74,7 @@ impl InstanceContainer {
entity_by_id: IntMap::default(), entity_by_id: IntMap::default(),
registries: RegistryHolder::default(), registries: RegistryHolder::default(),
})); }));
debug!("Added new instance {name}");
self.instances.insert(name, Arc::downgrade(&world)); self.instances.insert(name, Arc::downgrade(&world));
world world
} }

1
registries.txt Normal file
View file

@ -0,0 +1 @@
{}