mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
fix EntityPositionSync setting the wrong vec_delta_codec and also move into a RelativeEntityUpdate
This commit is contained in:
parent
1ae11f2d72
commit
efd31682c6
1 changed files with 58 additions and 58 deletions
|
@ -837,30 +837,29 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let entity = entity_id_index.get(&MinecraftEntityId(p.id));
|
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.id)) else {
|
||||||
|
|
||||||
if let Some(entity) = entity {
|
|
||||||
let new_pos = p.position;
|
|
||||||
let new_look_direction = LookDirection {
|
|
||||||
x_rot: (p.x_rot as i32 * 360) as f32 / 256.,
|
|
||||||
y_rot: (p.y_rot as i32 * 360) as f32 / 256.,
|
|
||||||
};
|
|
||||||
commands.entity(entity).queue(RelativeEntityUpdate {
|
|
||||||
partial_world: instance_holder.partial_instance.clone(),
|
|
||||||
update: Box::new(move |entity| {
|
|
||||||
let mut position = entity.get_mut::<Position>().unwrap();
|
|
||||||
if new_pos != **position {
|
|
||||||
**position = new_pos;
|
|
||||||
}
|
|
||||||
let mut look_direction = entity.get_mut::<LookDirection>().unwrap();
|
|
||||||
if new_look_direction != *look_direction {
|
|
||||||
*look_direction = new_look_direction;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
warn!("Got teleport entity packet for unknown entity id {}", p.id);
|
warn!("Got teleport entity packet for unknown entity id {}", p.id);
|
||||||
}
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
let new_pos = p.position;
|
||||||
|
let new_look_direction = LookDirection {
|
||||||
|
x_rot: (p.x_rot as i32 * 360) as f32 / 256.,
|
||||||
|
y_rot: (p.y_rot as i32 * 360) as f32 / 256.,
|
||||||
|
};
|
||||||
|
commands.entity(entity).queue(RelativeEntityUpdate {
|
||||||
|
partial_world: instance_holder.partial_instance.clone(),
|
||||||
|
update: Box::new(move |entity| {
|
||||||
|
let mut position = entity.get_mut::<Position>().unwrap();
|
||||||
|
if new_pos != **position {
|
||||||
|
**position = new_pos;
|
||||||
|
}
|
||||||
|
let mut look_direction = entity.get_mut::<LookDirection>().unwrap();
|
||||||
|
if new_look_direction != *look_direction {
|
||||||
|
*look_direction = new_look_direction;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
system_state.apply(ecs);
|
system_state.apply(ecs);
|
||||||
}
|
}
|
||||||
|
@ -878,6 +877,8 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
|
debug!("Got move entity pos packet {p:?}");
|
||||||
|
|
||||||
let entity = entity_id_index.get(&MinecraftEntityId(p.entity_id));
|
let entity = entity_id_index.get(&MinecraftEntityId(p.entity_id));
|
||||||
|
|
||||||
if let Some(entity) = entity {
|
if let Some(entity) = entity {
|
||||||
|
@ -918,6 +919,8 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
|
debug!("Got move entity pos rot packet {p:?}");
|
||||||
|
|
||||||
let entity = entity_id_index.get(&MinecraftEntityId(p.entity_id));
|
let entity = entity_id_index.get(&MinecraftEntityId(p.entity_id));
|
||||||
|
|
||||||
if let Some(entity) = entity {
|
if let Some(entity) = entity {
|
||||||
|
@ -1467,52 +1470,49 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientboundGamePacket::EntityPositionSync(p) => {
|
ClientboundGamePacket::EntityPositionSync(p) => {
|
||||||
debug!("Got entity position sync packet {p:?}");
|
|
||||||
|
|
||||||
let mut system_state: SystemState<(
|
let mut system_state: SystemState<(
|
||||||
Query<&EntityIdIndex>,
|
Commands,
|
||||||
Query<(
|
Query<(&EntityIdIndex, &InstanceHolder)>,
|
||||||
&mut Physics,
|
|
||||||
&mut Position,
|
|
||||||
&mut LastSentPosition,
|
|
||||||
&mut LookDirection,
|
|
||||||
Option<&LocalEntity>,
|
|
||||||
)>,
|
|
||||||
)> = SystemState::new(ecs);
|
)> = SystemState::new(ecs);
|
||||||
let (mut index_query, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let entity_id_index = index_query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.id)) else {
|
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.id)) else {
|
||||||
warn!(
|
warn!("Got teleport entity packet for unknown entity id {}", p.id);
|
||||||
"Got entity position sync packet for unknown entity id {}",
|
|
||||||
p.id
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Ok((
|
let new_position = p.values.pos;
|
||||||
mut physics,
|
let new_on_ground = p.on_ground;
|
||||||
mut position,
|
let new_look_direction = p.values.look_direction;
|
||||||
mut last_sent_position,
|
|
||||||
mut look_direction,
|
|
||||||
local_entity,
|
|
||||||
)) = query.get_mut(entity)
|
|
||||||
else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
physics.vec_delta_codec.set_base(**position);
|
commands.entity(entity).queue(RelativeEntityUpdate {
|
||||||
|
partial_world: instance_holder.partial_instance.clone(),
|
||||||
|
update: Box::new(move |entity_mut| {
|
||||||
|
let is_local_entity = entity_mut.get::<LocalEntity>().is_some();
|
||||||
|
let mut physics = entity_mut.get_mut::<Physics>().unwrap();
|
||||||
|
|
||||||
if local_entity.is_some() {
|
physics.vec_delta_codec.set_base(new_position);
|
||||||
debug!("Ignoring entity position sync packet for local player");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
**last_sent_position = **position;
|
if is_local_entity {
|
||||||
**position = p.values.pos;
|
debug!("Ignoring entity position sync packet for local player");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
*look_direction = p.values.look_direction;
|
physics.set_on_ground(new_on_ground);
|
||||||
|
|
||||||
physics.set_on_ground(p.on_ground);
|
let mut last_sent_position =
|
||||||
|
entity_mut.get_mut::<LastSentPosition>().unwrap();
|
||||||
|
**last_sent_position = new_position;
|
||||||
|
let mut position = entity_mut.get_mut::<Position>().unwrap();
|
||||||
|
**position = new_position;
|
||||||
|
|
||||||
|
let mut look_direction = entity_mut.get_mut::<LookDirection>().unwrap();
|
||||||
|
*look_direction = new_look_direction;
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
system_state.apply(ecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientboundGamePacket::SelectAdvancementsTab(_) => {}
|
ClientboundGamePacket::SelectAdvancementsTab(_) => {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue