Skip to content

Commit

Permalink
rename WorldPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Jan 12, 2025
1 parent 6415f69 commit 23dbb72
Show file tree
Hide file tree
Showing 41 changed files with 229 additions and 217 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- [x] Scoreboard
- [x] World Borders
- [x] World Saving
- [ ] Redstone
- [ ] Liquid Physics
- Player
- [x] Player Skins
- [x] Player Client brand
Expand Down
37 changes: 37 additions & 0 deletions pumpkin-config/src/chunk.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::str;

use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize, Default)]
#[serde(default)]
pub struct ChunkConfig {
pub compression: ChunkCompression,
}

#[derive(Deserialize, Serialize)]
pub struct ChunkCompression {
pub compression_algorithm: Compression,
pub compression_level: u32,
}

impl Default for ChunkCompression {
fn default() -> Self {
Self {
compression_algorithm: Compression::LZ4,
compression_level: 6,
}
}
}

#[derive(Deserialize, Serialize, Clone)]
#[repr(u8)]
pub enum Compression {
/// GZip Compression
GZip,
/// ZLib Compression
ZLib,
/// LZ4 Compression (since 24w04a)
LZ4,
/// Custom compression algorithm (since 24w05a)
Custom,
}
3 changes: 3 additions & 0 deletions pumpkin-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use chunk::ChunkConfig;
use log::warn;
use logging::LoggingConfig;
use pumpkin_util::{Difficulty, GameMode, PermissionLvl};
Expand Down Expand Up @@ -26,6 +27,7 @@ pub use server_links::ServerLinksConfig;

mod commands;

pub mod chunk;
pub mod op;
mod pvp;
mod server_links;
Expand All @@ -50,6 +52,7 @@ pub static BASIC_CONFIG: LazyLock<BasicConfiguration> = LazyLock::new(BasicConfi
pub struct AdvancedConfiguration {
pub logging: LoggingConfig,
pub resource_pack: ResourcePackConfig,
pub chunk: ChunkConfig,
pub networking: NetworkingConfig,
pub commands: CommandsConfig,
pub pvp: PVPConfig,
Expand Down
17 changes: 0 additions & 17 deletions pumpkin-config/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use serde::{Deserialize, Serialize};
#[serde(default)]
pub struct LoggingConfig {
pub enabled: bool,
pub level: LevelFilter,
pub env: bool,
pub threads: bool,
pub color: bool,
pub timestamp: bool,
Expand All @@ -15,24 +13,9 @@ impl Default for LoggingConfig {
fn default() -> Self {
Self {
enabled: true,
level: Default::default(),
env: false,
threads: true,
color: true,
timestamp: true,
}
}
}

#[derive(
Deserialize, Serialize, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash,
)]
pub enum LevelFilter {
Off,
Error,
Warn,
#[default]
Info,
Debug,
Trace,
}
12 changes: 6 additions & 6 deletions pumpkin-inventory/src/open_container.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::crafting::check_if_matches_crafting;
use crate::Container;
use pumpkin_data::screen::WindowType;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;
use pumpkin_world::block::block_registry::Block;
use pumpkin_world::item::ItemStack;
use std::sync::Arc;
Expand All @@ -12,7 +12,7 @@ pub struct OpenContainer {
// TODO: should this be uuid?
players: Vec<i32>,
container: Arc<Mutex<Box<dyn Container>>>,
location: Option<WorldPosition>,
location: Option<BlockPos>,
block: Option<Block>,
}

Expand Down Expand Up @@ -46,7 +46,7 @@ impl OpenContainer {

pub fn new_empty_container<C: Container + Default + 'static>(
player_id: i32,
location: Option<WorldPosition>,
location: Option<BlockPos>,
block: Option<Block>,
) -> Self {
Self {
Expand All @@ -57,7 +57,7 @@ impl OpenContainer {
}
}

pub fn is_location(&self, try_position: WorldPosition) -> bool {
pub fn is_location(&self, try_position: BlockPos) -> bool {
if let Some(location) = self.location {
location == try_position
} else {
Expand All @@ -81,11 +81,11 @@ impl OpenContainer {
self.players.len()
}

pub fn get_location(&self) -> Option<WorldPosition> {
pub fn get_location(&self) -> Option<BlockPos> {
self.location
}

pub async fn set_location(&mut self, location: Option<WorldPosition>) {
pub async fn set_location(&mut self, location: Option<BlockPos>) {
self.location = location;
}

Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_block_destroy_stage.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_data::packet::clientbound::PLAY_BLOCK_DESTRUCTION;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;

use pumpkin_macros::client_packet;
use serde::Serialize;
Expand All @@ -10,12 +10,12 @@ use crate::VarInt;
#[client_packet(PLAY_BLOCK_DESTRUCTION)]
pub struct CSetBlockDestroyStage {
entity_id: VarInt,
location: WorldPosition,
location: BlockPos,
destroy_stage: u8,
}

impl CSetBlockDestroyStage {
pub fn new(entity_id: VarInt, location: WorldPosition, destroy_stage: u8) -> Self {
pub fn new(entity_id: VarInt, location: BlockPos, destroy_stage: u8) -> Self {
Self {
entity_id,
location,
Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_block_event.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_data::packet::clientbound::PLAY_BLOCK_EVENT;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;

use pumpkin_macros::client_packet;
use serde::Serialize;
Expand All @@ -9,15 +9,15 @@ use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_BLOCK_EVENT)]
pub struct CBlockAction<'a> {
location: &'a WorldPosition,
location: &'a BlockPos,
action_id: u8,
action_parameter: u8,
block_type: VarInt,
}

impl<'a> CBlockAction<'a> {
pub fn new(
location: &'a WorldPosition,
location: &'a BlockPos,
action_id: u8,
action_parameter: u8,
block_type: VarInt,
Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_block_update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_data::packet::clientbound::PLAY_BLOCK_UPDATE;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;

use pumpkin_macros::client_packet;
use serde::Serialize;
Expand All @@ -9,12 +9,12 @@ use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_BLOCK_UPDATE)]
pub struct CBlockUpdate<'a> {
location: &'a WorldPosition,
location: &'a BlockPos,
block_id: VarInt,
}

impl<'a> CBlockUpdate<'a> {
pub fn new(location: &'a WorldPosition, block_id: VarInt) -> Self {
pub fn new(location: &'a BlockPos, block_id: VarInt) -> Self {
Self { location, block_id }
}
}
11 changes: 3 additions & 8 deletions pumpkin-protocol/src/client/play/c_level_event.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
use pumpkin_data::packet::clientbound::PLAY_LEVEL_EVENT;
use pumpkin_macros::client_packet;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;
use serde::Serialize;

#[derive(Serialize)]
#[client_packet(PLAY_LEVEL_EVENT)]
pub struct CLevelEvent {
event: i32,
location: WorldPosition,
location: BlockPos,
data: i32,
disable_relative_volume: bool,
}

impl CLevelEvent {
pub fn new(
event: i32,
location: WorldPosition,
data: i32,
disable_relative_volume: bool,
) -> Self {
pub fn new(event: i32, location: BlockPos, data: i32, disable_relative_volume: bool) -> Self {
Self {
event,
location,
Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_login.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_data::packet::clientbound::PLAY_LOGIN;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;

use pumpkin_macros::client_packet;
use serde::Serialize;
Expand Down Expand Up @@ -27,7 +27,7 @@ pub struct CLogin<'a> {
previous_gamemode: i8,
debug: bool,
is_flat: bool,
death_dimension_name: Option<(Identifier, WorldPosition)>,
death_dimension_name: Option<(Identifier, BlockPos)>,
portal_cooldown: VarInt,
sealevel: VarInt,
enforce_secure_chat: bool,
Expand All @@ -52,7 +52,7 @@ impl<'a> CLogin<'a> {
previous_gamemode: i8,
debug: bool,
is_flat: bool,
death_dimension_name: Option<(Identifier, WorldPosition)>,
death_dimension_name: Option<(Identifier, BlockPos)>,
portal_cooldown: VarInt,
sealevel: VarInt,
enforce_secure_chat: bool,
Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_respawn.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use pumpkin_data::packet::clientbound::PLAY_RESPAWN;
use pumpkin_macros::client_packet;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;
use serde::Serialize;

use crate::{codec::identifier::Identifier, VarInt};
Expand All @@ -15,7 +15,7 @@ pub struct CRespawn {
previous_gamemode: i8,
debug: bool,
is_flat: bool,
death_dimension_name: Option<(Identifier, WorldPosition)>,
death_dimension_name: Option<(Identifier, BlockPos)>,
portal_cooldown: VarInt,
sealevel: VarInt,
data_kept: u8,
Expand All @@ -31,7 +31,7 @@ impl CRespawn {
previous_gamemode: i8,
debug: bool,
is_flat: bool,
death_dimension_name: Option<(Identifier, WorldPosition)>,
death_dimension_name: Option<(Identifier, BlockPos)>,
portal_cooldown: VarInt,
sealevel: VarInt,
data_kept: u8,
Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_worldevent.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_data::packet::clientbound::PLAY_LEVEL_EVENT;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;

use pumpkin_macros::client_packet;
use serde::Serialize;
Expand All @@ -8,15 +8,15 @@ use serde::Serialize;
#[client_packet(PLAY_LEVEL_EVENT)]
pub struct CWorldEvent<'a> {
event: i32,
location: &'a WorldPosition,
location: &'a BlockPos,
data: i32,
disable_relative_volume: bool,
}

impl<'a> CWorldEvent<'a> {
pub fn new(
event: i32,
location: &'a WorldPosition,
location: &'a BlockPos,
data: i32,
disable_relative_volume: bool,
) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions pumpkin-protocol/src/server/play/s_pick_item.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use pumpkin_data::packet::serverbound::{PLAY_PICK_ITEM_FROM_BLOCK, PLAY_PICK_ITEM_FROM_ENTITY};
use pumpkin_macros::server_packet;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;
use serde::Deserialize;

#[derive(Deserialize)]
#[server_packet(PLAY_PICK_ITEM_FROM_BLOCK)]
pub struct SPickItemFromBlock {
pub pos: WorldPosition,
pub pos: BlockPos,
pub include_data: bool,
}

Expand Down
4 changes: 2 additions & 2 deletions pumpkin-protocol/src/server/play/s_player_action.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use pumpkin_data::packet::serverbound::PLAY_PLAYER_ACTION;
use pumpkin_macros::server_packet;
use pumpkin_util::math::position::WorldPosition;
use pumpkin_util::math::position::BlockPos;

use crate::VarInt;

#[derive(serde::Deserialize)]
#[server_packet(PLAY_PLAYER_ACTION)]
pub struct SPlayerAction {
pub status: VarInt,
pub location: WorldPosition,
pub location: BlockPos,
pub face: u8,
pub sequence: VarInt,
}
Expand Down
4 changes: 2 additions & 2 deletions pumpkin-protocol/src/server/play/s_use_item_on.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use pumpkin_data::packet::serverbound::PLAY_USE_ITEM_ON;
use pumpkin_macros::server_packet;
use pumpkin_util::math::{position::WorldPosition, vector3::Vector3};
use pumpkin_util::math::{position::BlockPos, vector3::Vector3};
use serde::Deserialize;

use crate::VarInt;
Expand All @@ -9,7 +9,7 @@ use crate::VarInt;
#[server_packet(PLAY_USE_ITEM_ON)]
pub struct SUseItemOn {
pub hand: VarInt,
pub location: WorldPosition,
pub location: BlockPos,
pub face: VarInt,
pub cursor_pos: Vector3<f32>,
pub inside_block: bool,
Expand Down
4 changes: 2 additions & 2 deletions pumpkin-util/src/math/boundingbox.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{position::WorldPosition, vector3::Vector3};
use super::{position::BlockPos, vector3::Vector3};

#[derive(Clone, Copy)]
pub struct BoundingBox {
Expand Down Expand Up @@ -38,7 +38,7 @@ impl BoundingBox {
}
}

pub fn from_block(position: &WorldPosition) -> Self {
pub fn from_block(position: &BlockPos) -> Self {
let position = position.0;
Self {
min_x: position.x as f64,
Expand Down
Loading

0 comments on commit 23dbb72

Please sign in to comment.