mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
from<ClientboundAddEntityPacket> for Entity
This commit is contained in:
parent
614b211298
commit
d8e0457b62
8 changed files with 48 additions and 13 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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" {
|
||||
|
|
Loading…
Add table
Reference in a new issue