From f42d630544165d11a544224ac273d6aaf89d8095 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Mon, 29 Aug 2022 20:41:01 -0500 Subject: Physics (#11) * Put physics module in azalea-entity * port aabb * add more stuff to PositionXYZ * azalea-physics * important collision things * more physics stuff * backup because i'm about to delete shapes * more shape stuff * CubeVoxelShape * no compile errors??? insane * impl VoxelShape for ArrayVoxelShape * Shapes stuff * collide_x but it doesn't work yet * binary_search * it compiles * Entity has bounding box * Update discrete_voxel_shape.rs * Entity::make_bounding_box * ok i'm about to merge az-entity and az-world might be a terrible idea which is why i'm committing first * ok so i moved entity to world * on_pos and move_entity compiles * add send_position * move collision stuff to collision module in az-physics * dimension is no longer an Option * start trying to do collision for the client * collision works :tada: * start adding palette resizing * get_and_set (pain) * it compiles but probably won't work * add a test * remove printlns * add more tests for palette stuff * ClientboundMoveVec3Packet -> ClientboundMoveEntityPosPacket i think i changed this on accident once * palette resizing works todo: remove the printlns * Remove printlns in palette.rs * fix issues from merge * fixes + work a bit more on physics * Better entities (#19) * well it compiles * add tests to entity storage * add suggestions in azalea-brigadier * this probably causes ub * fix brigadiersuggestions * get rid of entityid * test From for EntityRef * don't mention other libraries since there's too many * fix warnings * do todos in brigadier suggestions * work on physics * more physics stuff * remove trait feature on az-block i think rust gets confused and compiles the macro without the feature * bump ahash * aes tests in az-crypto * optimize aes's deps * fix crashes * fix section_index for negative numbers and test * fix BlockPos protocol implementation * remove some debug prints * prepare to add ai_step * make ai step work * clippy --- .../src/packets/game/clientbound_add_entity_packet.rs | 9 ++++----- .../src/packets/game/clientbound_add_player_packet.rs | 9 ++++----- .../src/packets/game/clientbound_light_update_packet.rs | 3 ++- .../src/packets/game/clientbound_player_chat_packet.rs | 6 ++++-- .../src/packets/game/clientbound_player_info_packet.rs | 14 ++++++++------ .../src/packets/game/clientbound_set_entity_data_packet.rs | 2 +- azalea-protocol/src/packets/game/mod.rs | 8 ++++---- .../src/packets/game/serverbound_interact_packet.rs | 9 ++++----- .../src/packets/game/serverbound_move_player_pos_packet.rs | 2 +- .../packets/game/serverbound_move_player_pos_rot_packet.rs | 2 +- .../src/packets/game/serverbound_move_player_rot_packet.rs | 2 +- .../game/serverbound_move_player_status_only_packet.rs | 2 +- .../src/packets/game/serverbound_use_item_on_packet.rs | 6 +++--- 13 files changed, 38 insertions(+), 36 deletions(-) mode change 100755 => 100644 azalea-protocol/src/packets/game/mod.rs (limited to 'azalea-protocol/src') diff --git a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs index b79646c0..4b26efe7 100644 --- a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs @@ -1,6 +1,6 @@ use azalea_buf::McBuf; -use azalea_core::EntityPos; -use azalea_entity::Entity; +use azalea_core::Vec3; +use azalea_world::entity::EntityData; use packet_macros::ClientboundGamePacket; use uuid::Uuid; @@ -26,12 +26,11 @@ pub struct ClientboundAddEntityPacket { pub z_vel: i16, } -impl From<&ClientboundAddEntityPacket> for Entity { +impl From<&ClientboundAddEntityPacket> for EntityData { fn from(p: &ClientboundAddEntityPacket) -> Self { Self::new( - p.id, p.uuid, - EntityPos { + Vec3 { x: p.x, y: p.y, z: p.z, diff --git a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs index 2e450084..cd07d033 100644 --- a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs @@ -1,6 +1,6 @@ use azalea_buf::McBuf; -use azalea_core::EntityPos; -use azalea_entity::Entity; +use azalea_core::Vec3; +use azalea_world::entity::EntityData; use packet_macros::ClientboundGamePacket; use uuid::Uuid; @@ -17,12 +17,11 @@ pub struct ClientboundAddPlayerPacket { pub y_rot: i8, } -impl From<&ClientboundAddPlayerPacket> for Entity { +impl From<&ClientboundAddPlayerPacket> for EntityData { fn from(p: &ClientboundAddPlayerPacket) -> Self { Self::new( - p.id, p.uuid, - EntityPos { + Vec3 { x: p.x, y: p.y, z: p.z, diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs index 038e6202..e7fa936f 100644 --- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs @@ -1,4 +1,5 @@ -use azalea_buf::{BitSet, McBuf}; +use azalea_buf::McBuf; +use azalea_core::BitSet; use packet_macros::ClientboundGamePacket; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs index 7414e10c..492f352f 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs @@ -1,6 +1,8 @@ -use azalea_buf::{BitSet, BufReadError, McBuf, McBufReadable, McBufVarWritable}; -use azalea_buf::{McBufVarReadable, McBufWritable}; +use azalea_buf::{ + BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, +}; use azalea_chat::component::Component; +use azalea_core::BitSet; use azalea_crypto::{MessageSignature, SignedMessageHeader}; use packet_macros::ClientboundGamePacket; use std::io::{Read, Write}; diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs index d53774b7..4c61d5c7 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs @@ -1,3 +1,4 @@ +use crate::packets::login::serverbound_hello_packet::ProfilePublicKeyData; use azalea_buf::{BufReadError, McBuf}; use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable}; use azalea_chat::component::Component; @@ -28,14 +29,15 @@ pub struct PlayerProperty { #[derive(Clone, Debug, McBuf)] pub struct AddPlayer { - uuid: Uuid, - name: String, - properties: Vec, + pub uuid: Uuid, + pub name: String, + pub properties: Vec, #[var] - gamemode: u32, + pub gamemode: u32, #[var] - ping: i32, - display_name: Option, + pub ping: i32, + pub display_name: Option, + pub profile_public_key: Option, } #[derive(Clone, Debug, McBuf)] diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs index 7468fc91..35319acc 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs @@ -1,5 +1,5 @@ use azalea_buf::McBuf; -use azalea_entity::EntityMetadata; +use azalea_world::entity::EntityMetadata; use packet_macros::ClientboundGamePacket; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs old mode 100755 new mode 100644 index 194c7680..ca647241 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -183,10 +183,10 @@ declare_state_packets!( 0x11: serverbound_jigsaw_generate_packet::ServerboundJigsawGeneratePacket, 0x12: serverbound_keep_alive_packet::ServerboundKeepAlivePacket, 0x13: serverbound_lock_difficulty_packet::ServerboundLockDifficultyPacket, - 0x14: serverbound_move_player_pos_packet::ServerboundMovePlayerPacketPos, - 0x15: serverbound_move_player_pos_rot_packet::ServerboundMovePlayerPacketPosRot, - 0x16: serverbound_move_player_rot_packet::ServerboundMovePlayerPacketRot, - 0x17: serverbound_move_player_status_only_packet::ServerboundMovePlayerPacketStatusOnly, + 0x14: serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket, + 0x15: serverbound_move_player_pos_rot_packet::ServerboundMovePlayerPosRotPacket, + 0x16: serverbound_move_player_rot_packet::ServerboundMovePlayerRotPacket, + 0x17: serverbound_move_player_status_only_packet::ServerboundMovePlayerStatusOnlyPacket, 0x18: serverbound_move_vehicle_packet::ServerboundMoveVehiclePacket, 0x19: serverbound_paddle_boat_packet::ServerboundPaddleBoatPacket, 0x1a: serverbound_pick_item_packet::ServerboundPickItemPacket, diff --git a/azalea-protocol/src/packets/game/serverbound_interact_packet.rs b/azalea-protocol/src/packets/game/serverbound_interact_packet.rs index 47843d47..7f54bd44 100644 --- a/azalea-protocol/src/packets/game/serverbound_interact_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_interact_packet.rs @@ -1,7 +1,6 @@ use crate::packets::BufReadError; -use azalea_buf::McBufVarReadable; -use azalea_buf::{McBuf, McBufReadable, McBufVarWritable, McBufWritable}; -use azalea_core::EntityPos; +use azalea_buf::{McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; +use azalea_core::Vec3; use packet_macros::ServerboundGamePacket; use std::io::{Read, Write}; @@ -21,7 +20,7 @@ pub enum ActionType { }, Attack, InteractAt { - location: EntityPos, + location: Vec3, hand: InteractionHand, }, } @@ -63,7 +62,7 @@ impl McBufReadable for ActionType { let z = f32::read_from(buf)?; let hand = InteractionHand::read_from(buf)?; Ok(ActionType::InteractAt { - location: EntityPos { + location: Vec3 { x: x as f64, y: y as f64, z: z as f64, diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_pos_packet.rs b/azalea-protocol/src/packets/game/serverbound_move_player_pos_packet.rs index 9e70eec6..aac85d6b 100644 --- a/azalea-protocol/src/packets/game/serverbound_move_player_pos_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_move_player_pos_packet.rs @@ -2,7 +2,7 @@ use azalea_buf::McBuf; use packet_macros::ServerboundGamePacket; #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] -pub struct ServerboundMovePlayerPacketPos { +pub struct ServerboundMovePlayerPosPacket { pub x: f64, pub y: f64, pub z: f64, diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_pos_rot_packet.rs b/azalea-protocol/src/packets/game/serverbound_move_player_pos_rot_packet.rs index 6933a724..a1ee359f 100644 --- a/azalea-protocol/src/packets/game/serverbound_move_player_pos_rot_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_move_player_pos_rot_packet.rs @@ -2,7 +2,7 @@ use azalea_buf::McBuf; use packet_macros::ServerboundGamePacket; #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] -pub struct ServerboundMovePlayerPacketPosRot { +pub struct ServerboundMovePlayerPosRotPacket { pub x: f64, pub y: f64, pub z: f64, diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_rot_packet.rs b/azalea-protocol/src/packets/game/serverbound_move_player_rot_packet.rs index 493c5eab..86a4669f 100644 --- a/azalea-protocol/src/packets/game/serverbound_move_player_rot_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_move_player_rot_packet.rs @@ -2,7 +2,7 @@ use azalea_buf::McBuf; use packet_macros::ServerboundGamePacket; #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] -pub struct ServerboundMovePlayerPacketRot { +pub struct ServerboundMovePlayerRotPacket { pub y_rot: f32, pub x_rot: f32, pub on_ground: bool, diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_status_only_packet.rs b/azalea-protocol/src/packets/game/serverbound_move_player_status_only_packet.rs index 8b08154b..64ba93ae 100644 --- a/azalea-protocol/src/packets/game/serverbound_move_player_status_only_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_move_player_status_only_packet.rs @@ -2,6 +2,6 @@ use azalea_buf::McBuf; use packet_macros::ServerboundGamePacket; #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] -pub struct ServerboundMovePlayerPacketStatusOnly { +pub struct ServerboundMovePlayerStatusOnlyPacket { pub on_ground: bool, } diff --git a/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs b/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs index f2fb1b2a..39762c2e 100644 --- a/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs @@ -1,6 +1,6 @@ use crate::packets::game::serverbound_interact_packet::InteractionHand; use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable}; -use azalea_core::{BlockPos, Direction, EntityPos}; +use azalea_core::{BlockPos, Direction, Vec3}; use packet_macros::ServerboundGamePacket; use std::io::{Read, Write}; @@ -16,7 +16,7 @@ pub struct ServerboundUseItemOnPacket { pub struct BlockHitResult { pub block_pos: BlockPos, pub direction: Direction, - pub location: EntityPos, + pub location: Vec3, pub inside: bool, } @@ -43,7 +43,7 @@ impl McBufReadable for BlockHitResult { Ok(Self { block_pos, direction, - location: EntityPos { + location: Vec3 { x: block_pos.x as f64 + cursor_x as f64, y: block_pos.y as f64 + cursor_y as f64, z: block_pos.z as f64 + cursor_z as f64, -- cgit v1.2.3