aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-client/src')
-rw-r--r--azalea-client/src/client.rs21
-rw-r--r--azalea-client/src/lib.rs4
-rw-r--r--azalea-client/src/local_player.rs15
-rw-r--r--azalea-client/src/packet_handling.rs21
4 files changed, 31 insertions, 30 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index 8f460da8..47cc7235 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -38,7 +38,7 @@ use azalea_protocol::{
};
use azalea_world::{
entity::{EntityPlugin, EntityUpdateSet, Local, WorldName},
- Instance, PartialWorld, WorldContainer,
+ Instance, InstanceContainer, PartialInstance,
};
use bevy_app::{App, CoreSchedule, Plugin, PluginGroup, PluginGroupBuilder};
use bevy_ecs::{
@@ -75,13 +75,13 @@ pub struct Client {
/// and skin data.
///
/// This is immutable; the server cannot change it. To get the username and
- /// skin the server chose for you, get your player from
- /// [`Self::players`].
+ /// skin the server chose for you, get your player from the [`TabList`]
+ /// component.
pub profile: GameProfile,
/// The entity for this client in the ECS.
pub entity: Entity,
/// The world that this client is in.
- pub world: Arc<RwLock<PartialWorld>>,
+ pub world: Arc<RwLock<PartialInstance>>,
/// The entity component system. You probably don't need to access this
/// directly. Note that if you're using a shared world (i.e. a swarm), this
@@ -94,8 +94,7 @@ pub struct Client {
/// A component that contains some of the "settings" for this client that are
/// sent to the server, such as render distance.
-#[derive(Component, Clone, Debug, Deref, DerefMut, Default, Eq, PartialEq)]
-pub struct ClientInformation(ServerboundClientInformationPacket);
+pub type ClientInformation = ServerboundClientInformationPacket;
/// A component that contains a map of player UUIDs to their information in the
/// tab list
@@ -137,7 +136,7 @@ impl Client {
profile,
// default our id to 0, it'll be set later
entity,
- world: Arc::new(RwLock::new(PartialWorld::default())),
+ world: Arc::new(RwLock::new(PartialInstance::default())),
ecs,
@@ -424,14 +423,14 @@ impl Client {
/// Get a reference to our (potentially shared) world.
///
- /// This gets the [`World`] from our world container. If it's a normal
+ /// This gets the [`Instance`] from our world container. If it's a normal
/// client, then it'll be the same as the world the client has loaded.
/// If the client using a shared world, then the shared world will be a
/// superset of the client's world.
pub fn world(&self) -> Arc<RwLock<Instance>> {
let world_name = self.component::<WorldName>();
let ecs = self.ecs.lock();
- let world_container = ecs.resource::<WorldContainer>();
+ let world_container = ecs.resource::<InstanceContainer>();
world_container.get(&world_name).unwrap()
}
@@ -464,7 +463,7 @@ impl Client {
{
let mut ecs = self.ecs.lock();
let mut client_information_mut = self.query::<&mut ClientInformation>(&mut ecs);
- **client_information_mut = client_information.clone();
+ *client_information_mut = client_information.clone();
}
if self.logged_in() {
@@ -514,7 +513,7 @@ impl Plugin for AzaleaPlugin {
app.add_event::<SendPacketEvent>()
.add_system(handle_send_packet_event);
- app.init_resource::<WorldContainer>();
+ app.init_resource::<InstanceContainer>();
}
}
diff --git a/azalea-client/src/lib.rs b/azalea-client/src/lib.rs
index 44a4db6b..8c3936cd 100644
--- a/azalea-client/src/lib.rs
+++ b/azalea-client/src/lib.rs
@@ -26,7 +26,9 @@ mod player;
pub mod task_pool;
pub use account::Account;
-pub use client::{init_ecs_app, start_ecs, Client, ClientInformation, JoinError};
+pub use client::{
+ init_ecs_app, start_ecs, Client, ClientInformation, JoinError, JoinedClientBundle, TabList,
+};
pub use events::Event;
pub use local_player::{GameProfileComponent, LocalPlayer};
pub use movement::{SprintDirection, StartSprintEvent, StartWalkEvent, WalkDirection};
diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs
index 7ec3d0dc..540ef3b4 100644
--- a/azalea-client/src/local_player.rs
+++ b/azalea-client/src/local_player.rs
@@ -5,7 +5,7 @@ use azalea_core::ChunkPos;
use azalea_protocol::packets::game::ServerboundGamePacket;
use azalea_world::{
entity::{self, Dead},
- Instance, PartialWorld,
+ Instance, PartialInstance,
};
use bevy_ecs::{
component::Component, entity::Entity, event::EventReader, query::Added, system::Query,
@@ -33,11 +33,12 @@ use crate::{
pub struct LocalPlayer {
packet_writer: mpsc::UnboundedSender<ServerboundGamePacket>,
- /// The partial world is the world this client currently has loaded. It has
- /// a limited render distance.
- pub partial_world: Arc<RwLock<PartialWorld>>,
- /// The world is the combined [`PartialWorld`]s of all clients in the same
- /// world. (Only relevant if you're using a shared world, i.e. a swarm)
+ /// The partial instance is the world this client currently has loaded. It
+ /// has a limited render distance.
+ pub partial_instance: Arc<RwLock<PartialInstance>>,
+ /// The world is the combined [`PartialInstance`]s of all clients in the
+ /// same world. (Only relevant if you're using a shared world, i.e. a
+ /// swarm)
pub world: Arc<RwLock<Instance>>,
/// A task that reads packets from the server. The client is disconnected
@@ -92,7 +93,7 @@ impl LocalPlayer {
packet_writer,
world,
- partial_world: Arc::new(RwLock::new(PartialWorld::new(
+ partial_instance: Arc::new(RwLock::new(PartialInstance::new(
client_information.view_distance.into(),
Some(entity),
))),
diff --git a/azalea-client/src/packet_handling.rs b/azalea-client/src/packet_handling.rs
index ae38ec5a..a75f2760 100644
--- a/azalea-client/src/packet_handling.rs
+++ b/azalea-client/src/packet_handling.rs
@@ -20,7 +20,7 @@ use azalea_world::{
MinecraftEntityId, Physics, PlayerBundle, Position, WorldName,
},
entity::{LoadedBy, RelativeEntityUpdate},
- PartialWorld, WorldContainer,
+ InstanceContainer, PartialInstance,
};
use bevy_app::{App, CoreSet, Plugin};
use bevy_ecs::{
@@ -192,7 +192,7 @@ fn process_packet_events(ecs: &mut World) {
&GameProfileComponent,
&ClientInformation,
)>,
- ResMut<WorldContainer>,
+ ResMut<InstanceContainer>,
)> = SystemState::new(ecs);
let (mut commands, mut query, mut world_container) = system_state.get_mut(ecs);
let (mut local_player, world_name, game_profile, client_information) =
@@ -231,7 +231,7 @@ fn process_packet_events(ecs: &mut World) {
// (when we add chunks or entities those will be in the
// world_container)
- *local_player.partial_world.write() = PartialWorld::new(
+ *local_player.partial_instance.write() = PartialInstance::new(
client_information.view_distance.into(),
// this argument makes it so other clients don't update this
// player entity
@@ -260,8 +260,7 @@ fn process_packet_events(ecs: &mut World) {
"Sending client information because login: {:?}",
client_information
);
- let client_information: ClientInformation = client_information.clone();
- local_player.write_packet((*client_information).clone().get());
+ local_player.write_packet(client_information.clone().get());
// brand
local_player.write_packet(
@@ -478,7 +477,7 @@ fn process_packet_events(ecs: &mut World) {
let mut system_state: SystemState<Query<&mut LocalPlayer>> = SystemState::new(ecs);
let mut query = system_state.get_mut(ecs);
let local_player = query.get_mut(player_entity).unwrap();
- let mut partial_world = local_player.partial_world.write();
+ let mut partial_world = local_player.partial_instance.write();
partial_world.chunks.view_center = ChunkPos::new(p.x, p.z);
}
@@ -497,14 +496,14 @@ fn process_packet_events(ecs: &mut World) {
// by this client.
let shared_chunk = local_player.world.read().chunks.get(&pos);
let this_client_has_chunk = local_player
- .partial_world
+ .partial_instance
.read()
.chunks
.limited_get(&pos)
.is_some();
let mut world = local_player.world.write();
- let mut partial_world = local_player.partial_world.write();
+ let mut partial_world = local_player.partial_instance.write();
if !this_client_has_chunk {
if let Some(shared_chunk) = shared_chunk {
@@ -673,7 +672,7 @@ fn process_packet_events(ecs: &mut World) {
if let Some(entity) = entity {
let new_position = p.position;
commands.entity(entity).add(RelativeEntityUpdate {
- partial_world: local_player.partial_world.clone(),
+ partial_world: local_player.partial_instance.clone(),
update: Box::new(move |entity| {
let mut position = entity.get_mut::<Position>().unwrap();
**position = new_position;
@@ -704,7 +703,7 @@ fn process_packet_events(ecs: &mut World) {
if let Some(entity) = entity {
let delta = p.delta.clone();
commands.entity(entity).add(RelativeEntityUpdate {
- partial_world: local_player.partial_world.clone(),
+ partial_world: local_player.partial_instance.clone(),
update: Box::new(move |entity_mut| {
let mut position = entity_mut.get_mut::<Position>().unwrap();
**position = position.with_delta(&delta);
@@ -732,7 +731,7 @@ fn process_packet_events(ecs: &mut World) {
if let Some(entity) = entity {
let delta = p.delta.clone();
commands.entity(entity).add(RelativeEntityUpdate {
- partial_world: local_player.partial_world.clone(),
+ partial_world: local_player.partial_instance.clone(),
update: Box::new(move |entity_mut| {
let mut position = entity_mut.get_mut::<Position>().unwrap();
**position = position.with_delta(&delta);