Skip to content

Commit

Permalink
fix some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Dec 11, 2024
1 parent 874b116 commit 2ee2cc0
Show file tree
Hide file tree
Showing 35 changed files with 102 additions and 137 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ There are several ways you can contribute to Pumpkin:

The Documentation of Pumpkin can be found at <https://snowiiii.github.io/Pumpkin/>

**Tip: [typos](https://github.com/crate-ci/typos) is a great Project to detect and automatically fix typos

### Coding Guidelines

- **Working with Tokio and Rayon:**
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-config/src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Default for CompressionConfig {

#[derive(Deserialize, Serialize, Clone)]
#[serde(default)]
/// We have this in a Seperate struct so we can use it outside of the Config
/// We have this in a Separate struct so we can use it outside of the Config
pub struct CompressionInfo {
/// The compression threshold used when compression is enabled
pub threshold: u32,
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-core/src/random/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ mod tests {
-1992287231i32,
),
("求同存异", 847053876),
// This might look wierd because hebrew is text is right to left
// This might look weird because hebrew is text is right to left
("אבְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ:", 1372570871),
("संस्कृत-", 1748614838),
("minecraft:offset", -920384768i32),
Expand Down
4 changes: 2 additions & 2 deletions pumpkin-core/src/text/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::Cow;

use serde::{Deserialize, Serialize};

use super::Text;
use super::TextComponent;

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(tag = "action", content = "contents", rename_all = "snake_case")]
Expand All @@ -28,6 +28,6 @@ pub enum HoverEvent<'a> {
kind: Option<Cow<'a, str>>,
/// Optional custom name for the entity
#[serde(default, skip_serializing_if = "Option::is_none")]
name: Option<Text<'a>>,
name: Option<Box<TextComponent<'a>>>,
},
}
9 changes: 3 additions & 6 deletions pumpkin-core/src/text/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ pub mod color;
pub mod hover;
pub mod style;

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(transparent)]
pub struct Text<'a>(pub Box<TextComponent<'a>>);

// Represents a Text component
/// Represents a Text component
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "camelCase")]
pub struct TextComponent<'a> {
Expand All @@ -29,6 +25,7 @@ pub struct TextComponent<'a> {
/// Also has `ClickEvent
#[serde(flatten)]
pub style: Style<'a>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
/// Extra text components
pub extra: Vec<TextComponent<'a>>,
}
Expand Down Expand Up @@ -228,7 +225,7 @@ pub enum TextContent<'a> {
Translate {
translate: Cow<'a, str>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
with: Vec<Text<'a>>,
with: Vec<TextComponent<'a>>,
},
/// Displays the name of one or more entities found by a selector.
EntityNames {
Expand Down
4 changes: 2 additions & 2 deletions pumpkin-protocol/src/bytebuf/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl ser::Error for SerializerError {
// Enums are written as a varint of the index
// Structs are ignored
// Iterables' values are written in order, but NO information (e.g. size) about the
// iterable itself is written (list sizes should be a seperate field)
// iterable itself is written (list sizes should be a separate field)
impl ser::Serializer for &mut Serializer {
type Ok = ();
type Error = SerializerError;
Expand Down Expand Up @@ -137,7 +137,7 @@ impl ser::Serializer for &mut Serializer {
Ok(())
}
fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
// here is where all arrays/list getting written, usally we prefix the length of every length with an var int. The problem is
// here is where all arrays/list getting written, usually we prefix the length of every length with an var int. The problem is
// that byte arrays also getting thrown in here, and we don't want to prefix them
Ok(self)
}
Expand Down
4 changes: 2 additions & 2 deletions pumpkin-protocol/src/client/play/c_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ impl ProtoNode<'_> {
name: _,
is_executable,
parser: _,
override_suggestion_type: override_suggestion_tpye,
override_suggestion_type,
} => {
let mut n = 2;
if override_suggestion_tpye.is_some() {
if override_suggestion_type.is_some() {
n |= Self::FLAG_HAS_SUGGESTION_TYPE
}
if is_executable {
Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_teleport_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use pumpkin_macros::client_packet;
use crate::{ClientPacket, PositionFlag, VarInt};

#[client_packet("play:teleport_entity")]
pub struct CTeleportEntitiy<'a> {
pub struct CTeleportEntity<'a> {
entity_id: VarInt,
position: Vector3<f64>,
delta: Vector3<f64>,
Expand All @@ -14,7 +14,7 @@ pub struct CTeleportEntitiy<'a> {
on_ground: bool,
}

impl<'a> CTeleportEntitiy<'a> {
impl<'a> CTeleportEntity<'a> {
pub fn new(
entity_id: VarInt,
position: Vector3<f64>,
Expand All @@ -36,7 +36,7 @@ impl<'a> CTeleportEntitiy<'a> {
}
}

impl ClientPacket for CTeleportEntitiy<'_> {
impl ClientPacket for CTeleportEntity<'_> {
fn write(&self, bytebuf: &mut crate::bytebuf::ByteBuffer) {
bytebuf.put_var_int(&self.entity_id);
bytebuf.put_f64(self.position.x);
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub const CURRENT_MC_PROTOCOL: u32 = 769;

pub const MAX_PACKET_SIZE: i32 = 2097152;

/// usally uses a namespace like "minecraft:thing"
/// usually uses a namespace like "minecraft:thing"
pub type Identifier = String;
pub type VarIntType = i32;
pub type VarLongType = i64;
Expand Down
8 changes: 2 additions & 6 deletions pumpkin-protocol/src/packet_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Cipher = cfb8::Decryptor<aes::Aes128>;

// Decoder: Client -> Server
// Supports ZLib decoding/decompression
// Supports Aes128 Encyption
// Supports Aes128 Encryption
pub struct PacketDecoder {
buf: BytesMut,
decompress_buf: BytesMut,
Expand Down Expand Up @@ -135,7 +135,7 @@ impl PacketDecoder {
}
}

/// Sets ZLib Deompression
/// Sets ZLib Decompression
pub fn set_compression(&mut self, compression: bool) {
self.compression = compression;
}
Expand Down Expand Up @@ -183,10 +183,6 @@ impl PacketDecoder {
pub enum PacketDecodeError {
#[error("failed to decode packet ID")]
DecodeID,
#[error("failed to write into decoder: {0}")]
FailedWrite(String),
#[error("failed to flush decoder")]
FailedFinish,
#[error("packet exceeds maximum length")]
TooLong,
#[error("packet length is out of bounds")]
Expand Down
19 changes: 4 additions & 15 deletions pumpkin-protocol/src/packet_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Cipher = cfb8::Encryptor<aes::Aes128>;

// Encoder: Server -> Client
// Supports ZLib endecoding/compression
// Supports Aes128 Encyption
// Supports Aes128 Encryption
pub struct PacketEncoder {
buf: BytesMut,
compress_buf: Vec<u8>,
Expand Down Expand Up @@ -65,7 +65,7 @@ impl PacketEncoder {
let compressed_size = self
.compressor
.zlib_compress(data_to_compress, &mut self.compress_buf)
.map_err(|_| PacketEncodeError::CompressionFailed)?;
.map_err(|e| PacketEncodeError::CompressionFailed(e.to_string()))?;

// Resize compress_buf to actual compressed size
self.compress_buf.resize(compressed_size, 0);
Expand Down Expand Up @@ -169,21 +169,10 @@ impl PacketEncoder {

#[derive(Error, Debug)]
pub enum PacketEncodeError {
#[error("failed to encode packet data")]
EncodeData,
#[error("failed to write encoded packet")]
EncodeFailedWrite,
#[error("packet exceeds maximum length")]
TooLong,
#[error("compression failed")]
CompressionFailed,
}

impl PacketEncodeError {
pub fn kickable(&self) -> bool {
// We no longer have a connection, so dont try to kick the player, just close
!matches!(self, Self::EncodeData | Self::EncodeFailedWrite)
}
#[error("compression failed {0}")]
CompressionFailed(String),
}

#[cfg(test)]
Expand Down
20 changes: 10 additions & 10 deletions pumpkin-protocol/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl RawQueryPacket {

match reader.read_u16().await.map_err(|_| ())? {
// Magic should always equal 65277
// Since it denotes the protocl being used
// Since it denotes the protocol being used
// Should not attempt to decode packets with other magic values
65277 => Ok(Self {
packet_type: PacketType::from_u8(reader.read_u8().await.map_err(|_| ())?)
Expand Down Expand Up @@ -52,7 +52,7 @@ impl SHandshake {
#[derive(PartialEq, Debug)]
pub struct SStatusRequest {
pub session_id: i32,
pub challange_token: i32,
pub challenge_token: i32,
// Full status request and basic status request are pretty much similar
// So might as just use the same struct
pub is_full_request: bool,
Expand All @@ -62,7 +62,7 @@ impl SStatusRequest {
pub async fn decode(packet: &mut RawQueryPacket) -> Result<Self, ()> {
Ok(Self {
session_id: packet.reader.read_i32().await.map_err(|_| ())?,
challange_token: packet.reader.read_i32().await.map_err(|_| ())?,
challenge_token: packet.reader.read_i32().await.map_err(|_| ())?,
is_full_request: {
let mut buf = [0; 4];

Expand All @@ -74,7 +74,7 @@ impl SStatusRequest {
Ok(0) => false,
Ok(4) => true,
_ => {
// Just ingnore malformed packets or errors
// Just ignore malformed packets or errors
return Err(());
}
}
Expand All @@ -88,7 +88,7 @@ pub struct CHandshake {
// For simplicity use a number type
// Should be encoded as string here
// Will be converted in encoding
pub challange_token: i32,
pub challenge_token: i32,
}

impl CHandshake {
Expand All @@ -99,10 +99,10 @@ impl CHandshake {
buf.write_u8(9).await.unwrap();
// Session ID
buf.write_i32(self.session_id).await.unwrap();
// Challange token
// Challenge token
// Use CString to add null terminator and ensure no null bytes in the middle of data
// Unwrap here since there should be no errors with nulls in the middle of data
let token = CString::new(self.challange_token.to_string()).unwrap();
let token = CString::new(self.challenge_token.to_string()).unwrap();
buf.extend_from_slice(token.as_bytes_with_nul());

buf
Expand Down Expand Up @@ -249,7 +249,7 @@ async fn test_handshake_response() {

let packet = CHandshake {
session_id: 1,
challange_token: 9513307,
challenge_token: 9513307,
};

assert_eq!(bytes, packet.encode().await)
Expand All @@ -265,7 +265,7 @@ async fn test_basic_stat_request() {

let actual_packet = SStatusRequest {
session_id: 1,
challange_token: 9513307,
challenge_token: 9513307,
is_full_request: false,
};

Expand Down Expand Up @@ -304,7 +304,7 @@ async fn test_full_stat_request() {

let actual_packet = SStatusRequest {
session_id: 1,
challange_token: 9513307,
challenge_token: 9513307,
is_full_request: true,
};

Expand Down
5 changes: 2 additions & 3 deletions pumpkin-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ impl Registry {
.wolf_variant
.iter()
.map(|s| {
// I present to you, A ugly hack which is done because Mojang developers decited to put is_<biome> instead of just <biome> on 3 wolf varients while all others have just the biome, this causes the client to not find the biome and disconnect
let varient = s.1.clone();
let variant = s.1.clone();
RegistryEntry {
entry_id: s.0,
data: pumpkin_nbt::serializer::to_bytes_unnamed(&varient).unwrap(),
data: pumpkin_nbt::serializer::to_bytes_unnamed(&variant).unwrap(),
}
})
.collect();
Expand Down
12 changes: 6 additions & 6 deletions pumpkin-world/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,22 +273,22 @@ impl ChunkData {
Some(d) => d,
};

// How many bits each block has in one of the pallete u64s
// How many bits each block has in one of the palette u64s
let block_bit_size = {
let size = 64 - (palette.len() as i64 - 1).leading_zeros();
max(4, size)
};
// How many blocks there are in one of the palletes u64s
let blocks_in_pallete = 64 / block_bit_size;
// How many blocks there are in one of the palettes u64s
let blocks_in_palette = 64 / block_bit_size;

let mask = (1 << block_bit_size) - 1;
'block_loop: for block in block_data.iter() {
for i in 0..blocks_in_pallete {
for i in 0..blocks_in_palette {
let index = (block >> (i * block_bit_size)) & mask;
let block = &palette[index as usize];

// TODO allow indexing blocks directly so we can just use block_index and save some time?
// this is fine because we initalized the heightmap of `blocks`
// this is fine because we initialized the heightmap of `blocks`
// from the cached value in the world file
blocks.set_block_no_heightmap_update(
ChunkRelativeBlockCoordinates {
Expand All @@ -301,7 +301,7 @@ impl ChunkData {

block_index += 1;

// if `SUBCHUNK_VOLUME `is not divisible by `blocks_in_pallete` the block_data
// if `SUBCHUNK_VOLUME `is not divisible by `blocks_in_palette` the block_data
// can sometimes spill into other subchunks. We avoid that by aborting early
if (block_index % SUBCHUNK_VOLUME) == 0 {
break 'block_loop;
Expand Down
4 changes: 2 additions & 2 deletions pumpkin-world/src/world_gen/noise/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl BaseRouter {
.clone()
.min(ConstantFunction::new(5f64).mul(CAVES_ENTRANCES_OVERWORLD.clone()));

let mapped_cave_entraces_overworld = RangeFunction::<
let mapped_cave_entrances_overworld = RangeFunction::<
NoEnvironment,
SharedComponentReference,
SharedComponentReference,
Expand All @@ -286,7 +286,7 @@ impl BaseRouter {

let blended_cave_entrances_overworld = apply_blend_density(apply_surface_slides(
amplified,
mapped_cave_entraces_overworld.into(),
mapped_cave_entrances_overworld.into(),
))
.min(CAVES_NOODLE_OVERWORLD.clone());

Expand Down
6 changes: 3 additions & 3 deletions pumpkin-world/src/world_gen/proto_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl ProtoChunk {
let horizontal_cell_block_count = self.sampler.horizontal_cell_block_count();
let vertical_cell_block_count = self.sampler.vertical_cell_block_count();

let horizonal_cells = CHUNK_DIM / horizontal_cell_block_count;
let horizontal_cells = CHUNK_DIM / horizontal_cell_block_count;

let min_y = self.sampler.min_y();
let minimum_cell_y = min_y / vertical_cell_block_count as i8;
Expand All @@ -133,10 +133,10 @@ impl ProtoChunk {
// - All unsafe functions are encapsulated and no mutable references are leaked
unsafe {
self.sampler.sample_start_density();
for cell_x in 0..horizonal_cells {
for cell_x in 0..horizontal_cells {
self.sampler.sample_end_density(cell_x);

for cell_z in 0..horizonal_cells {
for cell_z in 0..horizontal_cells {
for cell_y in (0..cell_height).rev() {
self.sampler.on_sampled_cell_corners(cell_y, cell_z);
for local_y in (0..vertical_cell_block_count).rev() {
Expand Down
Loading

0 comments on commit 2ee2cc0

Please sign in to comment.