Skip to content

Commit

Permalink
Fix deadlock in standard function
Browse files Browse the repository at this point in the history
  • Loading branch information
OfficialKris committed Dec 25, 2024
1 parent 9ff93f5 commit 035fd59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pumpkin/src/block/blocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ pub async fn standard_open_container<C: Container + Default + 'static>(
window_type: WindowType,
) {
let entity_id = player.entity_id();
let mut open_containers = server.open_containers.write().await;
// If container exists, add player to container, otherwise create new container
if let Some(container_id) = server.get_container_id(location, block.clone()).await {
let mut open_containers = server.open_containers.write().await;
log::debug!("Using previous standard container ID: {}", container_id);
if let Some(container) = open_containers.get_mut(&u64::from(container_id)) {
container.add_player(entity_id);
player.open_container.store(Some(container_id.into()));
}
} else {
let mut open_containers = server.open_containers.write().await;
let new_id = server.new_container_id();
log::debug!("Creating new standard container ID: {}", new_id);
let open_container =
Expand Down
1 change: 0 additions & 1 deletion pumpkin/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ impl Server {
}
}
}
log::error!("No container found... this should not happen.");

drop(open_containers);

Expand Down

0 comments on commit 035fd59

Please sign in to comment.