Skip to content

Commit

Permalink
Fix: Rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Aug 18, 2024
1 parent 4c34a98 commit 77b205a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pumpkin/src/client/player_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ impl Client {
entity.x = Self::clamp_horizontal(position_rotation.x);
entity.y = Self::clamp_vertical(position_rotation.feet_y);
entity.z = Self::clamp_horizontal(position_rotation.z);
entity.yaw = wrap_degrees(position_rotation.yaw).clamp(-90.0, 90.0) % 360.0;
entity.pitch = wrap_degrees(position_rotation.pitch) % 360.0;
entity.yaw = wrap_degrees(position_rotation.yaw) % 360.0;
entity.pitch = wrap_degrees(position_rotation.pitch).clamp(-90.0, 90.0) % 360.0;

// send new position to all other players
let on_ground = player.on_ground;
Expand Down Expand Up @@ -151,8 +151,8 @@ impl Client {
}
let player = self.player.as_mut().unwrap();
let entity = &mut player.entity;
entity.yaw = wrap_degrees(rotation.yaw).clamp(-90.0, 90.0) % 360.0;
entity.pitch = wrap_degrees(rotation.pitch) % 360.0;
entity.yaw = wrap_degrees(rotation.yaw) % 360.0;
entity.pitch = wrap_degrees(rotation.pitch).clamp(-90.0, 90.0) % 360.0;
// send new position to all other players
let on_ground = player.on_ground;
let entity_id = entity.entity_id;
Expand Down Expand Up @@ -314,6 +314,9 @@ impl Client {
&CHurtAnimation::new(&entity_id, 10.0),
)
}
if config.swing {

}
} else {
self.kick("Interacted with invalid entitiy id")
}
Expand Down
3 changes: 3 additions & 0 deletions pumpkin/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pub struct PVPConfig {
pub protect_creative: bool,
/// Has PVP Knockback?
pub knockback: bool,
/// Should player swing when attacking?
pub swing: bool,
}

impl Default for PVPConfig {
Expand All @@ -79,6 +81,7 @@ impl Default for PVPConfig {
hurt_animation: true,
protect_creative: true,
knockback: true,
swing: true,
}
}
}
Expand Down

0 comments on commit 77b205a

Please sign in to comment.