aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-18 14:08:34 -0500
committermat <github@matdoes.dev>2022-06-18 14:08:34 -0500
commitd8e0457b62f5826183671e5b05890b400be35709 (patch)
treed40dccc61a2e96d60e2f678bca075102b28232c8
parent614b21129804930159f041ce3f51202bc3e1c0b6 (diff)
downloadazalea-drasl-d8e0457b62f5826183671e5b05890b400be35709.tar.xz
from<ClientboundAddEntityPacket> for Entity
-rwxr-xr-xCargo.lock6
-rwxr-xr-xazalea-auth/Cargo.toml2
-rwxr-xr-xazalea-client/src/connect.rs16
-rwxr-xr-xazalea-core/Cargo.toml2
-rw-r--r--azalea-entity/Cargo.toml6
-rw-r--r--azalea-entity/src/lib.rs23
-rwxr-xr-xazalea-protocol/Cargo.toml2
-rw-r--r--bot/src/main.rs4
8 files changed, 48 insertions, 13 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c63ef7a8..74375949 100755
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -138,6 +138,8 @@ name = "azalea-entity"
version = "0.1.0"
dependencies = [
"azalea-core",
+ "azalea-protocol",
+ "uuid",
]
[[package]]
@@ -1436,9 +1438,9 @@ dependencies = [
[[package]]
name = "uuid"
-version = "0.8.2"
+version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
+checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f"
[[package]]
name = "version_check"
diff --git a/azalea-auth/Cargo.toml b/azalea-auth/Cargo.toml
index aa9b7bdb..a7a11b53 100755
--- a/azalea-auth/Cargo.toml
+++ b/azalea-auth/Cargo.toml
@@ -6,4 +6,4 @@ version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-uuid = "^0.8.2"
+uuid = "^1.1.2"
diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs
index 2deaab68..dd3162eb 100755
--- a/azalea-client/src/connect.rs
+++ b/azalea-client/src/connect.rs
@@ -1,5 +1,6 @@
use crate::Player;
use azalea_core::{resource_location::ResourceLocation, ChunkPos, EntityPos};
+use azalea_entity::Entity;
use azalea_protocol::{
connect::{GameConnection, HandshakeConnection},
packets::{
@@ -352,12 +353,15 @@ impl Client {
}
GamePacket::ClientboundAddEntityPacket(p) => {
println!("Got add entity packet {:?}", p);
- let pos = EntityPos {
- x: p.x,
- y: p.y,
- z: p.z,
- };
- p.id;
+ let entity = Entity::from(p);
+ state
+ .lock()
+ .await
+ .world
+ .as_mut()
+ .expect("World doesn't exist! We should've gotten a login packet by now.")
+ .entities
+ .insert(entity);
}
GamePacket::ClientboundSetEntityDataPacket(p) => {
// println!("Got set entity data packet {:?}", p);
diff --git a/azalea-core/Cargo.toml b/azalea-core/Cargo.toml
index d652a46e..27112b21 100755
--- a/azalea-core/Cargo.toml
+++ b/azalea-core/Cargo.toml
@@ -8,4 +8,4 @@ version = "0.1.0"
[dependencies]
azalea-chat = {path = "../azalea-chat"}
azalea-nbt = {path = "../azalea-nbt"}
-uuid = "^0.8.2"
+uuid = "^1.1.2"
diff --git a/azalea-entity/Cargo.toml b/azalea-entity/Cargo.toml
index bf1e64bc..ae23267e 100644
--- a/azalea-entity/Cargo.toml
+++ b/azalea-entity/Cargo.toml
@@ -7,3 +7,9 @@ version = "0.1.0"
[dependencies]
azalea-core = {path = "../azalea-core"}
+azalea-protocol = {path = "../azalea-protocol", optional = true}
+uuid = "^1.1.2"
+
+[features]
+default = ["protocol"]
+protocol = ["dep:azalea-protocol"]
diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs
index 0e0178b5..f9d808c2 100644
--- a/azalea-entity/src/lib.rs
+++ b/azalea-entity/src/lib.rs
@@ -1,9 +1,13 @@
use azalea_core::EntityPos;
+#[cfg(feature = "protocol")]
+use azalea_protocol::packets::game::clientbound_add_entity_packet::ClientboundAddEntityPacket;
+use uuid::Uuid;
#[derive(Default, Debug)]
pub struct Entity {
/// The incrementing numerical id of the entity.
pub id: u32,
+ pub uuid: Uuid,
pos: EntityPos,
}
@@ -18,6 +22,25 @@ impl Entity {
}
}
+#[cfg(feature = "protocol")]
+impl From<&azalea_protocol::packets::game::clientbound_add_entity_packet::ClientboundAddEntityPacket>
+ for Entity
+{
+ fn from(
+ p: &azalea_protocol::packets::game::clientbound_add_entity_packet::ClientboundAddEntityPacket,
+ ) -> Self {
+ Self {
+ id: p.id,
+ uuid: p.uuid,
+ pos: EntityPos {
+ x: p.x,
+ y: p.y,
+ z: p.z,
+ },
+ }
+ }
+}
+
// #[cfg(test)]
// mod tests {
// #[test]
diff --git a/azalea-protocol/Cargo.toml b/azalea-protocol/Cargo.toml
index 899b44a8..41879b61 100755
--- a/azalea-protocol/Cargo.toml
+++ b/azalea-protocol/Cargo.toml
@@ -26,4 +26,4 @@ thiserror = "^1.0.30"
tokio = {version = "^1.14.0", features = ["io-util", "net", "macros"]}
tokio-util = "^0.6.9"
trust-dns-resolver = "^0.20.3"
-uuid = "^0.8.2"
+uuid = "^1.1.2"
diff --git a/bot/src/main.rs b/bot/src/main.rs
index 2618675e..287dd4f6 100644
--- a/bot/src/main.rs
+++ b/bot/src/main.rs
@@ -6,7 +6,7 @@ async fn main() {
println!("Hello, world!");
// let address = "95.111.249.143:10000";
- let address = "localhost:51028";
+ let address = "localhost:52909";
// let response = azalea_client::ping::ping_server(&address.try_into().unwrap())
// .await
// .unwrap();
@@ -23,7 +23,7 @@ async fn main() {
Event::Chat(p) => {
let state = client.state.lock().await;
let world = state.world.as_ref().unwrap();
- // println!("{:?}", state.player.entity);
+ println!("{:?}", state.player.entity());
// world.get_block_state(state.player.entity.pos);
// println!("{}", p.message.to_ansi(None));
// if p.message.to_ansi(None) == "<py5> ok" {