aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/inventory.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-09-21 11:16:29 -0500
committerGitHub <noreply@github.com>2023-09-21 11:16:29 -0500
commit7b3e2e4bf793466a351510c7fbbd08234e93bb0e (patch)
tree7177a919de9982d9e3c7f36a76d2025696f465b6 /azalea-client/src/inventory.rs
parent83cce236145cdab1872a472a70943b669a880965 (diff)
downloadazalea-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-client/src/inventory.rs')
-rw-r--r--azalea-client/src/inventory.rs33
1 files changed, 21 insertions, 12 deletions
diff --git a/azalea-client/src/inventory.rs b/azalea-client/src/inventory.rs
index da5376fc..2e8478d4 100644
--- a/azalea-client/src/inventory.rs
+++ b/azalea-client/src/inventory.rs
@@ -25,7 +25,11 @@ use bevy_ecs::{
};
use log::warn;
-use crate::{client::PlayerAbilities, local_player::handle_send_packet_event, Client, LocalPlayer};
+use crate::{
+ local_player::{handle_send_packet_event, PlayerAbilities, SendPacketEvent},
+ respawn::perform_respawn,
+ Client,
+};
pub struct InventoryPlugin;
impl Plugin for InventoryPlugin {
@@ -45,7 +49,8 @@ impl Plugin for InventoryPlugin {
handle_client_side_close_container_event,
)
.chain()
- .in_set(InventorySet),
+ .in_set(InventorySet)
+ .before(perform_respawn),
);
}
}
@@ -599,12 +604,13 @@ pub struct CloseContainerEvent {
pub id: u8,
}
fn handle_container_close_event(
+ query: Query<(Entity, &InventoryComponent)>,
mut events: EventReader<CloseContainerEvent>,
mut client_side_events: EventWriter<ClientSideCloseContainerEvent>,
- query: Query<(&LocalPlayer, &InventoryComponent)>,
+ mut send_packet_events: EventWriter<SendPacketEvent>,
) {
for event in events.iter() {
- let (local_player, inventory) = query.get(event.entity).unwrap();
+ let (entity, inventory) = query.get(event.entity).unwrap();
if event.id != inventory.id {
warn!(
"Tried to close container with ID {}, but the current container ID is {}",
@@ -613,12 +619,13 @@ fn handle_container_close_event(
continue;
}
- local_player.write_packet(
- ServerboundContainerClosePacket {
+ send_packet_events.send(SendPacketEvent {
+ entity,
+ packet: ServerboundContainerClosePacket {
container_id: inventory.id,
}
.get(),
- );
+ });
client_side_events.send(ClientSideCloseContainerEvent {
entity: event.entity,
});
@@ -650,11 +657,12 @@ pub struct ContainerClickEvent {
pub operation: ClickOperation,
}
pub fn handle_container_click_event(
+ mut query: Query<(Entity, &mut InventoryComponent)>,
mut events: EventReader<ContainerClickEvent>,
- mut query: Query<(&mut InventoryComponent, &LocalPlayer)>,
+ mut send_packet_events: EventWriter<SendPacketEvent>,
) {
for event in events.iter() {
- let (mut inventory, local_player) = query.get_mut(event.entity).unwrap();
+ let (entity, mut inventory) = query.get_mut(event.entity).unwrap();
if inventory.id != event.window_id {
warn!(
"Tried to click container with ID {}, but the current container ID is {}",
@@ -678,8 +686,9 @@ pub fn handle_container_click_event(
}
}
- local_player.write_packet(
- ServerboundContainerClickPacket {
+ send_packet_events.send(SendPacketEvent {
+ entity,
+ packet: ServerboundContainerClickPacket {
container_id: event.window_id,
state_id: inventory.state_id,
slot_num: event.operation.slot_num().map(|n| n as i16).unwrap_or(-999),
@@ -689,7 +698,7 @@ pub fn handle_container_click_event(
carried_item: inventory.carried.clone(),
}
.get(),
- )
+ })
}
}