Skip to content

Commit

Permalink
wrap_comments = true
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Dec 9, 2022
1 parent f2076da commit 70e2dfe
Show file tree
Hide file tree
Showing 44 changed files with 258 additions and 163 deletions.
1 change: 0 additions & 1 deletion azalea-auth/src/sessionserver.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Tell Mojang you're joining a multiplayer server.
//!
use serde::Deserialize;
use serde_json::json;
use thiserror::Error;
Expand Down
5 changes: 4 additions & 1 deletion azalea-block/azalea-block-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {

let mut properties_with_name: Vec<PropertyWithNameAndDefault> =
Vec::with_capacity(block.properties_and_defaults.len());
// Used to determine the index of the property so we can optionally add a number to it
// Used to determine the index of the property so we can optionally add a number
// to it
let mut previous_names: Vec<String> = Vec::new();
for property in &block.properties_and_defaults {
let index: Option<usize> = if block
Expand All @@ -343,10 +344,12 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
} else {
None
};
// ```ignore
// let mut property_name = property_struct_names_to_names
// .get(&property.property_type.to_string())
// .unwrap_or_else(|| panic!("Property '{}' is bad", property.property_type))
// .clone();
// ```
let mut property_name = property_struct_names_to_names
.get(&property.name.to_string())
.cloned()
Expand Down
3 changes: 2 additions & 1 deletion azalea-brigadier/src/command_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ impl<S> CommandDispatcher<S> {
// consumer.on_command_complete(context, true, value);
successful_forks += 1;

// TODO: allow context_command to error and handle those errors
// TODO: allow context_command to error and handle those
// errors
}
}

Expand Down
6 changes: 4 additions & 2 deletions azalea-brigadier/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ impl<S> Clone for CommandNode<S> {
}

impl<S> CommandNode<S> {
/// Gets the literal, or panics. You should use match if you're not certain about the type.
/// Gets the literal, or panics. You should use match if you're not certain
/// about the type.
pub fn literal(&self) -> &Literal {
match self.value {
ArgumentBuilderType::Literal(ref literal) => literal,
_ => panic!("CommandNode::literal() called on non-literal node"),
}
}
/// Gets the argument, or panics. You should use match if you're not certain about the type.
/// Gets the argument, or panics. You should use match if you're not certain
/// about the type.
pub fn argument(&self) -> &Argument {
match self.value {
ArgumentBuilderType::Argument(ref argument) => argument,
Expand Down
3 changes: 2 additions & 1 deletion azalea-buf/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ fn read_utf_with_len(buf: &mut Cursor<&[u8]>, max_length: u32) -> Result<String,
}

// fast varints modified from https://github.com/luojia65/mc-varint/blob/master/src/lib.rs#L67
/// Read a single varint from the reader and return the value, along with the number of bytes read
/// Read a single varint from the reader and return the value, along with the
/// number of bytes read
// pub async fn read_varint_async(
// reader: &mut (dyn AsyncRead + Unpin + Send),
// ) -> Result<i32, BufReadError> {
Expand Down
12 changes: 7 additions & 5 deletions azalea-chat/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ impl Component {
/// [ANSI string](https://en.wikipedia.org/wiki/ANSI_escape_code), so you
/// can print it to your terminal and get styling.
///
/// This is technically a shortcut for [`Component::to_ansi_custom_style`] with a
/// default [`Style`] colored white.
/// This is technically a shortcut for [`Component::to_ansi_custom_style`]
/// with a default [`Style`] colored white.
///
/// # Examples
///
Expand Down Expand Up @@ -166,8 +166,9 @@ impl<'de> Deserialize<'de> for Component {
.ok_or_else(|| de::Error::custom("\"with\" must be an array"))?;
let mut with_array = Vec::with_capacity(with.len());
for item in with {
// if it's a string component with no styling and no siblings, just add a string to with_array
// otherwise add the component to the array
// if it's a string component with no styling and no siblings, just add a
// string to with_array otherwise add the component
// to the array
let c = Component::deserialize(item).map_err(de::Error::custom)?;
if let Component::Text(text_component) = c {
if text_component.base.siblings.is_empty()
Expand Down Expand Up @@ -253,7 +254,8 @@ impl<'de> Deserialize<'de> for Component {
));
}
let json_array = json.as_array().unwrap();
// the first item in the array is the one that we're gonna return, the others are siblings
// the first item in the array is the one that we're gonna return, the others
// are siblings
let mut component = Component::deserialize(&json_array[0]).map_err(de::Error::custom)?;
for i in 1..json_array.len() {
component.append(
Expand Down
3 changes: 2 additions & 1 deletion azalea-chat/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ impl Style {
if !before.underlined.unwrap_or(false) && after.underlined.unwrap_or(false) {
ansi_codes.push_str(Ansi::UNDERLINED);
}
// if strikethrough used to be false/default and now it's true, set strikethrough
// if strikethrough used to be false/default and now it's true, set
// strikethrough
if !before.strikethrough.unwrap_or(false) && after.strikethrough.unwrap_or(false) {
ansi_codes.push_str(Ansi::STRIKETHROUGH);
}
Expand Down
14 changes: 9 additions & 5 deletions azalea-chat/src/text_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ impl Serialize for TextComponent {
const LEGACY_FORMATTING_CODE_SYMBOL: char = '§';

/// Convert a legacy color code string into a Component
/// Technically in Minecraft this is done when displaying the text, but AFAIK it's the same as just doing it in TextComponent
/// Technically in Minecraft this is done when displaying the text, but AFAIK
/// it's the same as just doing it in TextComponent
pub fn legacy_color_code_to_text_component(legacy_color_code: &str) -> TextComponent {
let mut components: Vec<TextComponent> = Vec::with_capacity(1);
// iterate over legacy_color_code, if it starts with LEGACY_COLOR_CODE_SYMBOL then read the next character and get the style from that
// otherwise, add the character to the text
// iterate over legacy_color_code, if it starts with LEGACY_COLOR_CODE_SYMBOL
// then read the next character and get the style from that otherwise, add
// the character to the text

// we don't use a normal for loop since we need to be able to skip after reading the formatter code symbol
// we don't use a normal for loop since we need to be able to skip after reading
// the formatter code symbol
let mut i = 0;
while i < legacy_color_code.chars().count() {
if legacy_color_code.chars().nth(i).unwrap() == LEGACY_FORMATTING_CODE_SYMBOL {
Expand Down Expand Up @@ -72,7 +75,8 @@ pub fn legacy_color_code_to_text_component(legacy_color_code: &str) -> TextCompo
return TextComponent::new("".to_string());
}

// create the final component by using the first one as the base, and then adding the rest as siblings
// create the final component by using the first one as the base, and then
// adding the rest as siblings
let mut final_component = components.remove(0);
for component in components {
final_component.base.siblings.push(component.get());
Expand Down
3 changes: 2 additions & 1 deletion azalea-client/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ impl Account {
AuthOpts::Microsoft { email } => {
let new_account = Account::microsoft(email).await?;
let access_token = self
.access_token.as_ref()
.access_token
.as_ref()
.expect("Access token should always be set for Microsoft accounts");
let new_access_token = new_account
.access_token
Expand Down
18 changes: 11 additions & 7 deletions azalea-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ pub struct Client {

#[derive(Default)]
pub struct PhysicsState {
/// Minecraft only sends a movement packet either after 20 ticks or if the player moved enough. This is that tick counter.
/// Minecraft only sends a movement packet either after 20 ticks or if the
/// player moved enough. This is that tick counter.
pub position_remainder: u32,
pub was_sprinting: bool,
// Whether we're going to try to start sprinting this tick. Equivalent to
Expand Down Expand Up @@ -383,8 +384,8 @@ impl Client {
/// Start the protocol and game tick loop.
#[doc(hidden)]
pub fn start_tasks(&self, tx: Sender<Event>) {
// if you get an error right here that means you're doing something with locks wrong
// read the error to see where the issue is
// if you get an error right here that means you're doing something with locks
// wrong read the error to see where the issue is
// you might be able to just drop the lock or put it in its own scope to fix

let mut tasks = self.tasks.lock();
Expand Down Expand Up @@ -789,7 +790,8 @@ impl Client {
if let Some(mut entity) = world.entity_mut(p.id) {
entity.apply_metadata(&p.packed_items.0);
} else {
// warn!("Server sent an entity data packet for an entity id ({}) that we don't know about", p.id);
// warn!("Server sent an entity data packet for an entity id
// ({}) that we don't know about", p.id);
}
}
ClientboundGamePacket::UpdateAttributes(_p) => {
Expand Down Expand Up @@ -1041,7 +1043,8 @@ impl Client {
/// of the client's world.
///
/// # Panics
/// Panics if the client has not received the login packet yet. You can check this with [`Client::logged_in`].
/// Panics if the client has not received the login packet yet. You can
/// check this with [`Client::logged_in`].
pub fn world(&self) -> Arc<WeakWorld> {
let world_name = self.world_name.read();
let world_name = world_name
Expand Down Expand Up @@ -1086,8 +1089,9 @@ impl Client {
self.world_name.read().is_some()
}

/// Tell the server we changed our game options (i.e. render distance, main hand).
/// If this is not set before the login packet, the default will be sent.
/// Tell the server we changed our game options (i.e. render distance, main
/// hand). If this is not set before the login packet, the default will
/// be sent.
///
/// ```rust,no_run
/// # use azalea_client::{Client, ClientInformation};
Expand Down
16 changes: 10 additions & 6 deletions azalea-client/src/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ impl Client {
pub(crate) async fn send_position(&mut self) -> Result<(), MovePlayerError> {
let packet = {
self.send_sprinting_if_needed().await?;
// TODO: the camera being able to be controlled by other entities isn't implemented yet
// if !self.is_controlled_camera() { return };
// TODO: the camera being able to be controlled by other entities isn't
// implemented yet if !self.is_controlled_camera() { return };

let mut physics_state = self.physics_state.lock();

Expand All @@ -54,7 +54,8 @@ impl Client {

physics_state.position_remainder += 1;

// boolean sendingPosition = Mth.lengthSquared(xDelta, yDelta, zDelta) > Mth.square(2.0E-4D) || this.positionReminder >= 20;
// boolean sendingPosition = Mth.lengthSquared(xDelta, yDelta, zDelta) >
// Mth.square(2.0E-4D) || this.positionReminder >= 20;
let sending_position = ((x_delta.powi(2) + y_delta.powi(2) + z_delta.powi(2))
> 2.0e-4f64.powi(2))
|| physics_state.position_remainder >= 20;
Expand Down Expand Up @@ -155,7 +156,8 @@ impl Client {
Ok(())
}

// Set our current position to the provided Vec3, potentially clipping through blocks.
// Set our current position to the provided Vec3, potentially clipping through
// blocks.
pub async fn set_position(&mut self, new_pos: Vec3) -> Result<(), MovePlayerError> {
let player_entity_id = *self.entity_id.read();
let mut world_lock = self.world.write();
Expand Down Expand Up @@ -198,7 +200,8 @@ impl Client {
}

// TODO: food data and abilities
// let has_enough_food_to_sprint = self.food_data().food_level || self.abilities().may_fly;
// let has_enough_food_to_sprint = self.food_data().food_level ||
// self.abilities().may_fly;
let has_enough_food_to_sprint = true;

// TODO: double tapping w to sprint i think
Expand All @@ -223,7 +226,8 @@ impl Client {
player_entity.ai_step();
}

/// Update the impulse from self.move_direction. The multipler is used for sneaking.
/// Update the impulse from self.move_direction. The multipler is used for
/// sneaking.
pub(crate) fn tick_controls(&mut self, multiplier: Option<f32>) {
let mut physics_state = self.physics_state.lock();

Expand Down
3 changes: 2 additions & 1 deletion azalea-core/src/bitset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ impl BitSet {
}
}

/// Returns the maximum potential items in the BitSet. This will be divisible by 64.
/// Returns the maximum potential items in the BitSet. This will be
/// divisible by 64.
fn len(&self) -> usize {
self.data.len() * 64
}
Expand Down
9 changes: 6 additions & 3 deletions azalea-core/src/game_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ impl GameType {
}

pub fn short_name(&self) -> &'static str {
// TODO: these should be translated TranslatableComponent("selectWorld.gameMode." + string2)
// TODO: these should be translated
// TranslatableComponent("selectWorld.gameMode." + string2)
match self {
GameType::Survival => "Survival",
GameType::Creative => "Creative",
Expand All @@ -59,7 +60,8 @@ impl GameType {
}

pub fn long_name(&self) -> &'static str {
// TODO: These should be translated TranslatableComponent("gameMode." + string2);
// TODO: These should be translated TranslatableComponent("gameMode." +
// string2);
match self {
GameType::Survival => "Survival Mode",
GameType::Creative => "Creative Mode",
Expand Down Expand Up @@ -92,7 +94,8 @@ impl McBufWritable for GameType {
}
}

/// Rust doesn't let us `impl McBufReadable for Option<GameType>` so we have to make a new type :(
/// Rust doesn't let us `impl McBufReadable for Option<GameType>` so we have to
/// make a new type :(
#[derive(Hash, Copy, Clone, Debug)]
pub struct OptionalGameType(Option<GameType>);

Expand Down
6 changes: 4 additions & 2 deletions azalea-core/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ pub struct BlockPos {
vec3_impl!(BlockPos, i32);

impl BlockPos {
/// Get the absolute center of a block position by adding 0.5 to each coordinate.
/// Get the absolute center of a block position by adding 0.5 to each
/// coordinate.
pub fn center(&self) -> Vec3 {
Vec3 {
x: self.x as f64 + 0.5,
Expand Down Expand Up @@ -176,7 +177,8 @@ impl ChunkBlockPos {
}
}

/// The coordinates of a block inside a chunk section. Each coordinate must be in the range [0, 15].
/// The coordinates of a block inside a chunk section. Each coordinate must be
/// in the range [0, 15].
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct ChunkSectionBlockPos {
pub x: u8,
Expand Down
3 changes: 2 additions & 1 deletion azalea-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ pub fn encrypt(public_key: &[u8], nonce: &[u8]) -> Result<EncryptResult, String>
// generate a random 16-byte shared secret, to be used with the AES/CFB8
// stream cipher.
let secret_key = generate_secret_key();
// let hash = hex_digest(&digest_data(server_id.as_bytes(), public_key, &secret_key));
// let hash = hex_digest(&digest_data(server_id.as_bytes(), public_key,
// &secret_key));

// this.keybytes = Crypt.encryptUsingKey(publicKey, secretKey.getEncoded());
// this.nonce = Crypt.encryptUsingKey(publicKey, arrby);
Expand Down
4 changes: 2 additions & 2 deletions azalea-language/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use std::{collections::HashMap, fs::File};
// let mut file = File::open("en_us.json").unwrap();
// let mut contents = String::new();
// file.read_to_string(&mut contents).unwrap();
// let en_us: HashMap<String, String> = serde_json::from_str(&contents).unwrap();
// Language { storage: en_us }
// let en_us: HashMap<String, String> =
// serde_json::from_str(&contents).unwrap(); Language { storage: en_us }
// }

// pub fn get(&self, key: &str) -> Option<&str> {
Expand Down
Loading

0 comments on commit 70e2dfe

Please sign in to comment.