aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src
diff options
context:
space:
mode:
authorShayne Hartford <shaybox@shaybox.com>2024-10-21 20:21:38 -0400
committerGitHub <noreply@github.com>2024-10-21 19:21:38 -0500
commitcd2f298a62819a3fabc52ef17560c2124a74d555 (patch)
tree3e32e4ccc7d9f095696c8e23b688b06cf1188f76 /azalea-client/src
parent5535877a4bddcdc30ef8f752a90e6845b308c3c2 (diff)
downloadazalea-drasl-cd2f298a62819a3fabc52ef17560c2124a74d555.tar.xz
Rename InventoryComponent to Inventory to match other components (#177)
(cherry picked from commit 266058a8d441169b46ef819595eee62337ab324c)
Diffstat (limited to 'azalea-client/src')
-rw-r--r--azalea-client/src/client.rs4
-rw-r--r--azalea-client/src/interact.rs9
-rw-r--r--azalea-client/src/inventory.rs22
-rw-r--r--azalea-client/src/mining.rs12
-rw-r--r--azalea-client/src/packet_handling/configuration.rs2
-rw-r--r--azalea-client/src/packet_handling/game.rs8
6 files changed, 26 insertions, 31 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index 6cb590df..0d0b18f0 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -6,7 +6,7 @@ use crate::{
disconnect::{DisconnectEvent, DisconnectPlugin},
events::{Event, EventPlugin, LocalPlayerEvents},
interact::{CurrentSequenceNumber, InteractPlugin},
- inventory::{InventoryComponent, InventoryPlugin},
+ inventory::{Inventory, InventoryPlugin},
local_player::{
death_event, GameProfileComponent, Hunger, InstanceHolder, PermissionLevel,
PlayerAbilities, TabList,
@@ -688,7 +688,7 @@ pub struct LocalPlayerBundle {
pub struct JoinedClientBundle {
// note that InstanceHolder isn't here because it's set slightly before we fully join the world
pub physics_state: PhysicsState,
- pub inventory: InventoryComponent,
+ pub inventory: Inventory,
pub tab_list: TabList,
pub current_sequence_number: CurrentSequenceNumber,
pub last_sent_direction: LastSentLookDirection,
diff --git a/azalea-client/src/interact.rs b/azalea-client/src/interact.rs
index 7b14be09..94b60ddc 100644
--- a/azalea-client/src/interact.rs
+++ b/azalea-client/src/interact.rs
@@ -33,7 +33,7 @@ use tracing::warn;
use crate::{
attack::handle_attack_event,
- inventory::{InventoryComponent, InventorySet},
+ inventory::{Inventory, InventorySet},
local_player::{LocalGameMode, PermissionLevel, PlayerAbilities},
movement::MoveEventsSet,
packet_handling::game::{handle_send_packet_event, SendPacketEvent},
@@ -237,7 +237,7 @@ pub fn check_is_interaction_restricted(
instance: &Instance,
block_pos: &BlockPos,
game_mode: &GameMode,
- inventory: &InventoryComponent,
+ inventory: &Inventory,
) -> bool {
match game_mode {
GameMode::Adventure => {
@@ -314,10 +314,7 @@ pub fn handle_swing_arm_event(
#[allow(clippy::type_complexity)]
fn update_modifiers_for_held_item(
- mut query: Query<
- (&mut Attributes, &InventoryComponent),
- (With<LocalEntity>, Changed<InventoryComponent>),
- >,
+ mut query: Query<(&mut Attributes, &Inventory), (With<LocalEntity>, Changed<Inventory>)>,
) {
for (mut attributes, inventory) in &mut query {
let held_item = inventory.held_item();
diff --git a/azalea-client/src/inventory.rs b/azalea-client/src/inventory.rs
index 97eb98ea..d4ccab14 100644
--- a/azalea-client/src/inventory.rs
+++ b/azalea-client/src/inventory.rs
@@ -67,14 +67,14 @@ impl Client {
/// have the player's inventory.
pub fn menu(&self) -> Menu {
let mut ecs = self.ecs.lock();
- let inventory = self.query::<&InventoryComponent>(&mut ecs);
+ let inventory = self.query::<&Inventory>(&mut ecs);
inventory.menu().clone()
}
}
/// A component present on all local players that have an inventory.
#[derive(Component, Debug, Clone)]
-pub struct InventoryComponent {
+pub struct Inventory {
/// A component that contains the player's inventory menu. This is
/// guaranteed to be a `Menu::Player`.
///
@@ -118,7 +118,7 @@ pub struct InventoryComponent {
pub selected_hotbar_slot: u8,
}
-impl InventoryComponent {
+impl Inventory {
/// Returns a reference to the currently active menu. If a container is open
/// it'll return [`Self::container_menu`], otherwise
/// [`Self::inventory_menu`].
@@ -563,9 +563,9 @@ fn get_quick_craft_slot_count(
item.count += slot_item_count;
}
-impl Default for InventoryComponent {
+impl Default for Inventory {
fn default() -> Self {
- InventoryComponent {
+ Inventory {
inventory_menu: Menu::Player(azalea_inventory::Player::default()),
id: 0,
container_menu: None,
@@ -591,7 +591,7 @@ pub struct MenuOpenedEvent {
}
fn handle_menu_opened_event(
mut events: EventReader<MenuOpenedEvent>,
- mut query: Query<&mut InventoryComponent>,
+ mut query: Query<&mut Inventory>,
) {
for event in events.read() {
let mut inventory = query.get_mut(event.entity).unwrap();
@@ -613,7 +613,7 @@ pub struct CloseContainerEvent {
pub id: u8,
}
fn handle_container_close_event(
- query: Query<(Entity, &InventoryComponent)>,
+ query: Query<(Entity, &Inventory)>,
mut events: EventReader<CloseContainerEvent>,
mut client_side_events: EventWriter<ClientSideCloseContainerEvent>,
mut send_packet_events: EventWriter<SendPacketEvent>,
@@ -650,7 +650,7 @@ pub struct ClientSideCloseContainerEvent {
}
pub fn handle_client_side_close_container_event(
mut events: EventReader<ClientSideCloseContainerEvent>,
- mut query: Query<&mut InventoryComponent>,
+ mut query: Query<&mut Inventory>,
) {
for event in events.read() {
let mut inventory = query.get_mut(event.entity).unwrap();
@@ -667,7 +667,7 @@ pub struct ContainerClickEvent {
pub operation: ClickOperation,
}
pub fn handle_container_click_event(
- mut query: Query<(Entity, &mut InventoryComponent)>,
+ mut query: Query<(Entity, &mut Inventory)>,
mut events: EventReader<ContainerClickEvent>,
mut send_packet_events: EventWriter<SendPacketEvent>,
) {
@@ -722,7 +722,7 @@ pub struct SetContainerContentEvent {
}
fn handle_set_container_content_event(
mut events: EventReader<SetContainerContentEvent>,
- mut query: Query<&mut InventoryComponent>,
+ mut query: Query<&mut Inventory>,
) {
for event in events.read() {
let mut inventory = query.get_mut(event.entity).unwrap();
@@ -753,7 +753,7 @@ pub struct SetSelectedHotbarSlotEvent {
fn handle_set_selected_hotbar_slot_event(
mut events: EventReader<SetSelectedHotbarSlotEvent>,
mut send_packet_events: EventWriter<SendPacketEvent>,
- mut query: Query<&mut InventoryComponent>,
+ mut query: Query<&mut Inventory>,
) {
for event in events.read() {
let mut inventory = query.get_mut(event.entity).unwrap();
diff --git a/azalea-client/src/mining.rs b/azalea-client/src/mining.rs
index bda14db0..86a0193c 100644
--- a/azalea-client/src/mining.rs
+++ b/azalea-client/src/mining.rs
@@ -16,7 +16,7 @@ use crate::{
can_use_game_master_blocks, check_is_interaction_restricted, CurrentSequenceNumber,
HitResultComponent, SwingArmEvent,
},
- inventory::{InventoryComponent, InventorySet},
+ inventory::{Inventory, InventorySet},
local_player::{LocalGameMode, PermissionLevel, PlayerAbilities},
movement::MoveEventsSet,
packet_handling::game::SendPacketEvent,
@@ -99,7 +99,7 @@ fn handle_auto_mine(
&HitResultComponent,
Entity,
Option<&Mining>,
- &InventoryComponent,
+ &Inventory,
&MineBlockPos,
&MineItem,
),
@@ -193,7 +193,7 @@ fn handle_start_mining_block_with_direction_event(
mut query: Query<(
&InstanceName,
&LocalGameMode,
- &InventoryComponent,
+ &Inventory,
&FluidOnEyes,
&Physics,
Option<&Mining>,
@@ -359,7 +359,7 @@ pub struct AttackBlockEvent {
/// mining.
fn is_same_mining_target(
target_block: BlockPos,
- inventory: &InventoryComponent,
+ inventory: &Inventory,
current_mining_pos: &MineBlockPos,
current_mining_item: &MineItem,
) -> bool {
@@ -423,7 +423,7 @@ fn handle_finish_mining_block_event(
mut query: Query<(
&InstanceName,
&LocalGameMode,
- &InventoryComponent,
+ &Inventory,
&PlayerAbilities,
&PermissionLevel,
&mut CurrentSequenceNumber,
@@ -522,7 +522,7 @@ fn continue_mining_block(
Entity,
&InstanceName,
&LocalGameMode,
- &InventoryComponent,
+ &Inventory,
&MineBlockPos,
&MineItem,
&FluidOnEyes,
diff --git a/azalea-client/src/packet_handling/configuration.rs b/azalea-client/src/packet_handling/configuration.rs
index 1be34a12..de365394 100644
--- a/azalea-client/src/packet_handling/configuration.rs
+++ b/azalea-client/src/packet_handling/configuration.rs
@@ -123,7 +123,7 @@ pub fn process_packet_events(ecs: &mut World) {
.remove::<InConfigurationState>()
.insert(crate::JoinedClientBundle {
physics_state: crate::PhysicsState::default(),
- inventory: crate::inventory::InventoryComponent::default(),
+ inventory: crate::inventory::Inventory::default(),
tab_list: crate::local_player::TabList::default(),
current_sequence_number: crate::interact::CurrentSequenceNumber::default(),
last_sent_direction: crate::movement::LastSentLookDirection::default(),
diff --git a/azalea-client/src/packet_handling/game.rs b/azalea-client/src/packet_handling/game.rs
index daa420c3..13183e7a 100644
--- a/azalea-client/src/packet_handling/game.rs
+++ b/azalea-client/src/packet_handling/game.rs
@@ -39,8 +39,7 @@ use crate::{
chunks,
disconnect::DisconnectEvent,
inventory::{
- ClientSideCloseContainerEvent, InventoryComponent, MenuOpenedEvent,
- SetContainerContentEvent,
+ ClientSideCloseContainerEvent, Inventory, MenuOpenedEvent, SetContainerContentEvent,
},
local_player::{
GameProfileComponent, Hunger, InstanceHolder, LocalGameMode, PlayerAbilities, TabList,
@@ -1144,7 +1143,7 @@ pub fn process_packet_events(ecs: &mut World) {
debug!("Got container set content packet {p:?}");
let mut system_state: SystemState<(
- Query<&mut InventoryComponent>,
+ Query<&mut Inventory>,
EventWriter<SetContainerContentEvent>,
)> = SystemState::new(ecs);
let (mut query, mut events) = system_state.get_mut(ecs);
@@ -1183,8 +1182,7 @@ pub fn process_packet_events(ecs: &mut World) {
ClientboundGamePacket::ContainerSetSlot(p) => {
debug!("Got container set slot packet {p:?}");
- let mut system_state: SystemState<Query<&mut InventoryComponent>> =
- SystemState::new(ecs);
+ let mut system_state: SystemState<Query<&mut Inventory>> = SystemState::new(ecs);
let mut query = system_state.get_mut(ecs);
let mut inventory = query.get_mut(player_entity).unwrap();