diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 97af3f5b6..8238f7db1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -41,7 +41,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest, ubuntu-24.04-arm] + os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-latest, macos-15-intel] toolchain: - stable steps: @@ -55,7 +55,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest, ubuntu-24.04-arm] + os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-latest, macos-15-intel] toolchain: - stable steps: diff --git a/pumpkin-data/build/block.rs b/pumpkin-data/build/block.rs index 40edfbb45..777cdc090 100644 --- a/pumpkin-data/build/block.rs +++ b/pumpkin-data/build/block.rs @@ -886,9 +886,8 @@ pub(crate) fn build() -> TokenStream { matches!(state_id, #random_tick_state_ids) } - pub fn blocks_movement(block_state: &BlockState) -> bool { + pub fn blocks_movement(block_state: &BlockState, block: &Block) -> bool { if block_state.is_solid() { - let block = Block::from_state_id(block_state.id); return block != &Block::COBWEB && block != &Block::BAMBOO_SAPLING; } false diff --git a/pumpkin-protocol/src/bedrock/client/level_chunk.rs b/pumpkin-protocol/src/bedrock/client/level_chunk.rs index 7b4a46eb6..7eac01b8c 100644 --- a/pumpkin-protocol/src/bedrock/client/level_chunk.rs +++ b/pumpkin-protocol/src/bedrock/client/level_chunk.rs @@ -22,8 +22,8 @@ pub struct CLevelChunk<'a> { impl<'a> PacketWrite for CLevelChunk<'a> { fn write(&self, writer: &mut W) -> Result<(), Error> { - VarInt(self.chunk.position.x).write(writer)?; - VarInt(self.chunk.position.y).write(writer)?; + VarInt(self.chunk.x).write(writer)?; + VarInt(self.chunk.z).write(writer)?; VarInt(self.dimension).write(writer)?; let sub_chunk_count = self.chunk.section.sections.len() as u32; diff --git a/pumpkin-protocol/src/bedrock/packet_decoder.rs b/pumpkin-protocol/src/bedrock/packet_decoder.rs index 6b2980c04..9756b68e2 100644 --- a/pumpkin-protocol/src/bedrock/packet_decoder.rs +++ b/pumpkin-protocol/src/bedrock/packet_decoder.rs @@ -134,7 +134,7 @@ impl UDPNetworkDecoder { err => PacketDecodeError::MalformedLength(err.to_string()), })?; - let packet_len = packet_len.0 as u64; + let packet_len = packet_len.0 as usize; let var_header = VarUInt::decode(&mut reader)?; @@ -157,7 +157,7 @@ impl UDPNetworkDecoder { let gamepacket_id = (header & 0x3FF) as u16; // 0x3FF is 10 bits set to 1 let payload = reader - .read_boxed_slice(packet_len as usize - var_header.written_size()) + .read_boxed_slice(packet_len - var_header.written_size()) .map_err(|err| PacketDecodeError::FailedDecompression(err.to_string()))?; Ok(RawPacket { diff --git a/pumpkin-protocol/src/java/client/play/chunk_data.rs b/pumpkin-protocol/src/java/client/play/chunk_data.rs index 27880370c..85fed1357 100644 --- a/pumpkin-protocol/src/java/client/play/chunk_data.rs +++ b/pumpkin-protocol/src/java/client/play/chunk_data.rs @@ -17,9 +17,9 @@ impl ClientPacket for CChunkData<'_> { let mut write = write; // Chunk X - write.write_i32_be(self.0.position.x)?; + write.write_i32_be(self.0.x)?; // Chunk Z - write.write_i32_be(self.0.position.y)?; + write.write_i32_be(self.0.z)?; let heightmaps = &self.0.heightmap; write.write_var_int(&VarInt(3))?; // Map size diff --git a/pumpkin-protocol/src/java/client/play/multi_block_update.rs b/pumpkin-protocol/src/java/client/play/multi_block_update.rs index 0e46912e9..6616c2d24 100644 --- a/pumpkin-protocol/src/java/client/play/multi_block_update.rs +++ b/pumpkin-protocol/src/java/client/play/multi_block_update.rs @@ -43,7 +43,7 @@ impl Serialize for CMultiBlockUpdate { ))?; for (position, state_id) in &self.positions_to_state_ids { - let long = ((*state_id as u64) << 12) | (*position as u64); + let long = (*state_id as u64) << 12 | (*position as u64); let var_long = VarLong::from(long as i64); tuple.serialize_element(&var_long)?; } diff --git a/pumpkin-util/src/biome.rs b/pumpkin-util/src/biome.rs index 5096d217f..220edb551 100644 --- a/pumpkin-util/src/biome.rs +++ b/pumpkin-util/src/biome.rs @@ -2,10 +2,7 @@ use std::sync::LazyLock; use serde::Deserialize; -use crate::{ - math::vector3::Vector3, noise::simplex::OctaveSimplexNoiseSampler, - random::legacy_rand::LegacyRand, -}; +use crate::{noise::simplex::OctaveSimplexNoiseSampler, random::legacy_rand::LegacyRand}; pub static TEMPERATURE_NOISE: LazyLock = LazyLock::new(|| { let mut rand = LegacyRand::from_seed(1234); @@ -30,20 +27,17 @@ pub enum TemperatureModifier { } impl TemperatureModifier { - pub fn convert_temperature(&self, pos: &Vector3, temperature: f32) -> f32 { + pub fn convert_temperature(&self, x: f64, z: f64, temperature: f32) -> f32 { match self { TemperatureModifier::None => temperature, TemperatureModifier::Frozen => { let frozen_ocean_sample = - FROZEN_OCEAN_NOISE.sample(pos.x as f64 * 0.05, pos.z as f64 * 0.05, false) - * 7.0; - let foliage_sample = - FOLIAGE_NOISE.sample(pos.x as f64 * 0.2, pos.z as f64 * 0.2, false); + FROZEN_OCEAN_NOISE.sample(x * 0.05, z * 0.05, false) * 7.0; + let foliage_sample = FOLIAGE_NOISE.sample(x * 0.2, z * 0.2, false); let threshold = frozen_ocean_sample + foliage_sample; if threshold < 0.3 { - let foliage_sample = - FOLIAGE_NOISE.sample(pos.x as f64 * 0.09, pos.z as f64 * 0.09, false); + let foliage_sample = FOLIAGE_NOISE.sample(x * 0.09, z * 0.09, false); if foliage_sample < 0.8 { return 0.2f32; } @@ -81,19 +75,18 @@ impl Weather { } /// This is an expensive function and should be cached - pub fn compute_temperature(&self, pos: &Vector3, sea_level: i32) -> f32 { - let modified_temperature = self - .temperature_modifier - .convert_temperature(pos, self.temperature); + pub fn compute_temperature(&self, x: f64, y: i32, z: f64, sea_level: i32) -> f32 { + let modified_temperature = + self.temperature_modifier + .convert_temperature(x, z, self.temperature); let offset_sea_level = sea_level + 17; - if pos.y > offset_sea_level { + if y > offset_sea_level { let temperature_noise = - (TEMPERATURE_NOISE.sample(pos.x as f64 / 8.0, pos.z as f64 / 8.0, false) * 8.0) - as f32; + (TEMPERATURE_NOISE.sample(x / 8.0, z / 8.0, false) * 8.0) as f32; modified_temperature - - (temperature_noise + pos.y as f32 - offset_sea_level as f32) * 0.05f32 / 40.0f32 + - (temperature_noise + y as f32 - offset_sea_level as f32) * 0.05f32 / 40.0f32 } else { modified_temperature } diff --git a/pumpkin-util/src/math/mod.rs b/pumpkin-util/src/math/mod.rs index 5dbe48349..2fce3aca5 100644 --- a/pumpkin-util/src/math/mod.rs +++ b/pumpkin-util/src/math/mod.rs @@ -71,13 +71,7 @@ pub const fn floor_log2(value: u32) -> u8 { } pub const fn smallest_encompassing_power_of_two(value: u32) -> u32 { - let mut i = value - 1; - i |= i >> 1; - i |= i >> 2; - i |= i >> 4; - i |= i >> 8; - i |= i >> 16; - i + 1 + value.next_power_of_two() } #[inline] diff --git a/pumpkin-util/src/text/mod.rs b/pumpkin-util/src/text/mod.rs index b3a62a4ae..35becbeca 100644 --- a/pumpkin-util/src/text/mod.rs +++ b/pumpkin-util/src/text/mod.rs @@ -82,7 +82,7 @@ pub struct TextComponentBase { /// Style of the text. Bold, Italic, underline, Color... /// Also has `ClickEvent #[serde(flatten)] - pub style: Style, + pub style: Box