-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(world): implement Chunk and Dimension improvements
- Rewrite Chunk to use Section data structure for better organization - Optimize Dimension to use DashMap for chunk storage - Implement Item and BlockItem traits for future item system - Update world and entity modules to accommodate new changes
- Loading branch information
Showing
10 changed files
with
215 additions
and
58 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use crate::registry::protocol_id::get_protocol_id; | ||
use downcast_rs::{impl_downcast, DowncastSync}; | ||
|
||
pub trait Item: Send + Sync + DowncastSync { | ||
fn get_builder(&self) -> &ItemBuilder; | ||
} | ||
impl_downcast!(sync Item); | ||
|
||
pub trait BlockItem: Item { | ||
fn get_block() -> u32; | ||
} | ||
|
||
pub struct ItemBuilder { | ||
pub protocol_id: u32, | ||
pub item_settings: ItemSettings, | ||
} | ||
|
||
impl ItemBuilder { | ||
fn new(id: &str, item_settings: ItemSettings) -> ItemBuilder { | ||
ItemBuilder { | ||
protocol_id: get_protocol_id("minecraft:item", &id).unwrap(), | ||
item_settings, | ||
} | ||
} | ||
} | ||
|
||
pub struct ItemSettings { | ||
pub max_count: u8, | ||
pub max_damage: u16, | ||
pub fireproof: bool, | ||
} | ||
|
||
impl ItemSettings { | ||
pub fn new() -> ItemSettings { | ||
ItemSettings { | ||
max_count: 64, | ||
max_damage: 0, | ||
fireproof: false, | ||
} | ||
} | ||
pub fn max_count(mut self, max_count: u8) -> ItemSettings { | ||
self.max_count = max_count; | ||
self | ||
} | ||
pub fn max_damage(mut self, max_damage: u16) -> ItemSettings { | ||
self.max_damage = max_damage; | ||
self | ||
} | ||
pub fn fireproof(mut self) -> ItemSettings { | ||
self.fireproof = true; | ||
self | ||
} | ||
} | ||
|
||
impl Default for ItemSettings { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.