mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-19 22:52:32 +00:00
physics stuff
This commit is contained in:
parent
d9d7b87d61
commit
c1af5d15e3
4 changed files with 19 additions and 14 deletions
|
@ -716,6 +716,7 @@ impl Client {
|
|||
if let Err(e) = client.send_position().await {
|
||||
println!("Error sending position: {:?}", e);
|
||||
}
|
||||
client.ai_step();
|
||||
|
||||
// TODO: minecraft does ambient sounds here
|
||||
|
||||
|
|
|
@ -303,6 +303,7 @@ const X_OFFSET: u64 = PACKED_Y_LENGTH + PACKED_Z_LENGTH;
|
|||
impl McBufReadable for BlockPos {
|
||||
fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> {
|
||||
let val = u64::read_from(buf)?;
|
||||
println!("reading blockpos from {}", val);
|
||||
let x = (val << 64 - X_OFFSET - PACKED_X_LENGTH >> 64 - PACKED_X_LENGTH) as i32;
|
||||
let y = (val << 64 - PACKED_Y_LENGTH >> 64 - PACKED_Y_LENGTH) as i32;
|
||||
let z = (val << 64 - Z_OFFSET - PACKED_Z_LENGTH >> 64 - PACKED_Z_LENGTH) as i32;
|
||||
|
|
|
@ -34,7 +34,10 @@ impl HasPhysics for EntityMut<'_> {
|
|||
let block_below: Box<dyn Block> = block_state_below.into();
|
||||
block_below.behavior().friction
|
||||
} else {
|
||||
unreachable!("Block below should be a real block.")
|
||||
unreachable!(
|
||||
"Block below at {:?} should be a real block.",
|
||||
block_pos_below
|
||||
)
|
||||
};
|
||||
|
||||
let inertia = if self.on_ground {
|
||||
|
@ -86,10 +89,10 @@ impl HasPhysics for EntityMut<'_> {
|
|||
|
||||
fn get_block_pos_below_that_affects_movement(entity: &EntityData) -> BlockPos {
|
||||
BlockPos::new(
|
||||
entity.pos().x as i32,
|
||||
entity.pos().x.floor() as i32,
|
||||
// TODO: this uses bounding_box.min_y instead of position.y
|
||||
(entity.pos().y - 0.5f64) as i32,
|
||||
entity.pos().z as i32,
|
||||
(entity.pos().y - 0.5f64).floor() as i32,
|
||||
entity.pos().z.floor() as i32,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -55,16 +55,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
// client.move_entity()
|
||||
|
||||
// println!("{}", m.to_ansi(None));
|
||||
if let Err(e) = client
|
||||
.move_entity(&Vec3 {
|
||||
x: 0.,
|
||||
y: -0.5,
|
||||
z: 0.,
|
||||
})
|
||||
.await
|
||||
{
|
||||
eprintln!("{:?}", e);
|
||||
}
|
||||
// if let Err(e) = client
|
||||
// .move_entity(&Vec3 {
|
||||
// x: 0.,
|
||||
// y: -0.5,
|
||||
// z: 0.,
|
||||
// })
|
||||
// .await
|
||||
// {
|
||||
// eprintln!("{:?}", e);
|
||||
// }
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue