mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
remove debug messages
This commit is contained in:
parent
f19e196d3a
commit
42da7795a5
5 changed files with 9 additions and 80 deletions
|
@ -843,11 +843,7 @@ impl Client {
|
|||
debug!("Got set experience packet {:?}", p);
|
||||
}
|
||||
ClientboundGamePacket::TeleportEntity(p) => {
|
||||
let a_start = Instant::now();
|
||||
let mut world_lock = client.world.write();
|
||||
let a_elapsed = a_start.elapsed();
|
||||
let b_start = Instant::now();
|
||||
info!("a");
|
||||
let _ = world_lock.set_entity_pos(
|
||||
p.id,
|
||||
Vec3 {
|
||||
|
@ -856,14 +852,6 @@ impl Client {
|
|||
z: p.z,
|
||||
},
|
||||
);
|
||||
let b_elapsed = b_start.elapsed();
|
||||
|
||||
if a_start.elapsed() > Duration::from_millis(1) {
|
||||
warn!(
|
||||
"Set entity pos took too long: {:?} {:?}",
|
||||
a_elapsed, b_elapsed
|
||||
);
|
||||
}
|
||||
}
|
||||
ClientboundGamePacket::UpdateAdvancements(p) => {
|
||||
debug!("Got update advancements packet {:?}", p);
|
||||
|
@ -1022,34 +1010,18 @@ impl Client {
|
|||
game_tick_interval.set_missed_tick_behavior(time::MissedTickBehavior::Burst);
|
||||
loop {
|
||||
game_tick_interval.tick().await;
|
||||
let start = Instant::now();
|
||||
Self::game_tick(&mut client, &tx).await;
|
||||
let elapsed = start.elapsed();
|
||||
if elapsed > time::Duration::from_millis(50) {
|
||||
warn!("Game tick took too long: {:?}", elapsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs every 50 milliseconds.
|
||||
async fn game_tick(client: &mut Client, tx: &UnboundedSender<Event>) {
|
||||
// return if there's no chunk at the player's position
|
||||
let game_tick_start = Instant::now();
|
||||
|
||||
{
|
||||
let a_start = Instant::now();
|
||||
let world_lock = client.world.read();
|
||||
let a_elapsed = a_start.elapsed();
|
||||
|
||||
let b_start = Instant::now();
|
||||
let player_entity_id = *client.entity_id.read();
|
||||
let b_elapsed = b_start.elapsed();
|
||||
|
||||
let c_start = Instant::now();
|
||||
let player_entity = world_lock.entity(player_entity_id);
|
||||
let c_elapsed = c_start.elapsed();
|
||||
|
||||
let d_start = Instant::now();
|
||||
let Some(player_entity) = player_entity else {
|
||||
return;
|
||||
};
|
||||
|
@ -1057,40 +1029,16 @@ impl Client {
|
|||
if world_lock.get_chunk(&player_chunk_pos).is_none() {
|
||||
return;
|
||||
}
|
||||
let d_elapsed = d_start.elapsed();
|
||||
|
||||
if a_start.elapsed() > time::Duration::from_millis(20) {
|
||||
warn!("a_elapsed: {:?}", a_elapsed);
|
||||
warn!("b_elapsed: {:?}", b_elapsed);
|
||||
warn!("c_elapsed: {:?}", c_elapsed);
|
||||
warn!("d_elapsed: {:?}", d_elapsed);
|
||||
}
|
||||
}
|
||||
let check_chunk_elapsed = game_tick_start.elapsed();
|
||||
|
||||
tx.send(Event::Tick).unwrap();
|
||||
|
||||
// TODO: if we're a passenger, send the required packets
|
||||
|
||||
let send_position_start = Instant::now();
|
||||
if let Err(e) = client.send_position().await {
|
||||
warn!("Error sending position: {:?}", e);
|
||||
}
|
||||
let send_position_elapsed = send_position_start.elapsed();
|
||||
let ai_step_start = Instant::now();
|
||||
client.ai_step();
|
||||
let ai_step_elapsed = ai_step_start.elapsed();
|
||||
|
||||
let game_tick_elapsed = game_tick_start.elapsed();
|
||||
if game_tick_elapsed > time::Duration::from_millis(50) {
|
||||
warn!(
|
||||
"(internal) game tick took too long: {:?}",
|
||||
game_tick_elapsed
|
||||
);
|
||||
warn!("check_chunk_elapsed: {:?}", check_chunk_elapsed);
|
||||
warn!("send_position_elapsed: {:?}", send_position_elapsed);
|
||||
warn!("ai_step_elapsed: {:?}", ai_step_elapsed);
|
||||
}
|
||||
|
||||
// TODO: minecraft does ambient sounds here
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use azalea_protocol::packets::game::{
|
|||
serverbound_move_player_status_only_packet::ServerboundMovePlayerStatusOnlyPacket,
|
||||
};
|
||||
use azalea_world::MoveEntityError;
|
||||
use log::info;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
@ -35,7 +36,6 @@ impl From<MoveEntityError> for MovePlayerError {
|
|||
impl Client {
|
||||
/// This gets called automatically every tick.
|
||||
pub(crate) async fn send_position(&mut self) -> Result<(), MovePlayerError> {
|
||||
info!("{} send position", self.profile.name);
|
||||
let packet = {
|
||||
self.send_sprinting_if_needed().await?;
|
||||
// TODO: the camera being able to be controlled by other entities isn't implemented yet
|
||||
|
|
|
@ -77,31 +77,17 @@ impl World {
|
|||
}
|
||||
|
||||
pub fn set_entity_pos(&mut self, entity_id: u32, new_pos: Vec3) -> Result<(), MoveEntityError> {
|
||||
info!("b");
|
||||
let a_start = Instant::now();
|
||||
let mut entity = self.entity_mut(entity_id).ok_or_else(|| {
|
||||
warn!("!!! a_elapsed: {:?}", a_start.elapsed());
|
||||
MoveEntityError::EntityDoesNotExist(Backtrace::capture())
|
||||
})?;
|
||||
let a_elapsed = a_start.elapsed();
|
||||
|
||||
let b_start = Instant::now();
|
||||
let mut entity = self
|
||||
.entity_mut(entity_id)
|
||||
.ok_or_else(|| MoveEntityError::EntityDoesNotExist(Backtrace::capture()))?;
|
||||
let old_chunk = ChunkPos::from(entity.pos());
|
||||
let new_chunk = ChunkPos::from(&new_pos);
|
||||
// this is fine because we update the chunk below
|
||||
unsafe { entity.move_unchecked(new_pos) };
|
||||
let b_elapsed = b_start.elapsed();
|
||||
let c_start = Instant::now();
|
||||
if old_chunk != new_chunk {
|
||||
self.entity_storage
|
||||
.update_entity_chunk(entity_id, &old_chunk, &new_chunk);
|
||||
}
|
||||
let c_elapsed = c_start.elapsed();
|
||||
|
||||
warn!(
|
||||
"!!! a_elapsed: {:?}, b_elapsed: {:?}, c_elapsed: {:?}",
|
||||
a_elapsed, b_elapsed, c_elapsed
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -110,15 +96,9 @@ impl World {
|
|||
entity_id: u32,
|
||||
delta: &PositionDelta8,
|
||||
) -> Result<(), MoveEntityError> {
|
||||
let owner_entity_id = self.entity_storage.owner_entity_id;
|
||||
let mut entity = self
|
||||
.entity_mut(entity_id)
|
||||
.ok_or_else(|| MoveEntityError::EntityDoesNotExist(Backtrace::capture()))?;
|
||||
if entity_id == owner_entity_id {
|
||||
println!("moving entity {} (self)", entity_id);
|
||||
} else {
|
||||
println!("moving entity {}", entity_id);
|
||||
}
|
||||
let new_pos = entity.pos().with_delta(delta);
|
||||
|
||||
let old_chunk = ChunkPos::from(entity.pos());
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{Client, Event};
|
|||
use async_trait::async_trait;
|
||||
use azalea_core::{BlockPos, CardinalDirection};
|
||||
use azalea_world::entity::EntityData;
|
||||
use log::debug;
|
||||
use log::{debug, info};
|
||||
use mtdstarlite::Edge;
|
||||
pub use mtdstarlite::MTDStarLite;
|
||||
use parking_lot::Mutex;
|
||||
|
|
|
@ -42,7 +42,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
let mut accounts = Vec::new();
|
||||
let mut states = Vec::new();
|
||||
|
||||
for i in 0..5 {
|
||||
for i in 0..1 {
|
||||
accounts.push(Account::offline(&format!("bot{}", i)));
|
||||
states.push(State::default());
|
||||
}
|
||||
|
@ -82,13 +82,12 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<
|
|||
}
|
||||
let entity = bot
|
||||
.world
|
||||
.lock()
|
||||
.read()
|
||||
.entity_by_uuid(&uuid::uuid!("6536bfed-8695-48fd-83a1-ecd24cf2a0fd"));
|
||||
if let Some(entity) = entity {
|
||||
if m.content() == "goto" {
|
||||
let target_pos_vec3 = entity.pos();
|
||||
let target_pos: BlockPos = target_pos_vec3.into();
|
||||
println!("target_pos: {:?}", target_pos);
|
||||
bot.goto(BlockPosGoal::from(target_pos));
|
||||
} else if m.content() == "look" {
|
||||
let target_pos_vec3 = entity.pos();
|
||||
|
@ -102,6 +101,8 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<
|
|||
} else if m.content() == "stop" {
|
||||
bot.set_jumping(false);
|
||||
bot.walk(WalkDirection::None);
|
||||
} else if m.content() == "lag" {
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue