-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
105 additions
and
10 deletions.
There are no files selected for viewing
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,25 @@ | ||
[package] | ||
name = "rimecraft-block" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["JieningYu <[email protected]>"] | ||
description = "Minecraft Block primitives" | ||
repository = "https://github.com/rimecraft-rs/rimecraft/" | ||
license = "AGPL-3.0-or-later" | ||
categories = [] | ||
|
||
[badges] | ||
maintenance = { status = "passively-maintained" } | ||
|
||
[dependencies] | ||
rimecraft-registry = { path = "../../util/registry" } | ||
rimecraft-state = { path = "../state", optional = true } | ||
serde = { version = "1.0", optional = true } | ||
|
||
[features] | ||
default = ["state"] | ||
serde = ["dep:serde"] | ||
state = ["dep:rimecraft-state"] | ||
|
||
[lints] | ||
workspace = true |
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,63 @@ | ||
//! Minecraft Block primitives. | ||
|
||
use rimecraft_registry::Reg; | ||
|
||
use std::marker::PhantomData; | ||
|
||
/// Block containing settings. | ||
#[derive(Debug)] | ||
pub struct RawBlock<P> { | ||
settings: Settings, | ||
_marker: PhantomData<P>, | ||
} | ||
|
||
impl<P> RawBlock<P> { | ||
/// Creates a new `Block` with the given settings. | ||
#[inline] | ||
pub const fn new(settings: Settings) -> Self { | ||
Self { | ||
settings, | ||
_marker: PhantomData, | ||
} | ||
} | ||
|
||
/// Returns the settings of the block. | ||
#[inline] | ||
pub fn settings(&self) -> &Settings { | ||
&self.settings | ||
} | ||
} | ||
|
||
impl<P> From<Settings> for RawBlock<P> { | ||
#[inline] | ||
fn from(settings: Settings) -> Self { | ||
Self::new(settings) | ||
} | ||
} | ||
|
||
/// A voxel in a `World`. | ||
pub type Block<'r, K, P> = Reg<'r, K, RawBlock<P>>; | ||
|
||
/// Settings of a block. | ||
#[derive(Debug, Clone, Copy, PartialEq, Default)] | ||
pub struct Settings { | ||
/// Whether this block can be collided with. | ||
pub collidable: bool, | ||
/// The resistance of this block. | ||
pub resistance: f32, | ||
/// The hardness of this block. | ||
pub hardness: f32, | ||
/// Whether this block accepts random ticks. | ||
pub random_ticks: bool, | ||
/// Whether this block is air. | ||
pub is_air: bool, | ||
/// Whether this block is opaque. | ||
pub opaque: bool, | ||
} | ||
|
||
#[doc(alias = "BlockProperties")] | ||
pub use Settings as BlockSettings; | ||
|
||
/// Represents a block state. | ||
#[cfg(feature = "state")] | ||
pub type BlockState<'s, 'r, K, P> = rimecraft_state::State<'s, Reg<'r, K, RawBlock<P>>>; |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name = "rimecraft-item" | |
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["JieningYu <[email protected]>"] | ||
description = "Minecraft Item primitives and registry" | ||
description = "Minecraft Item primitives" | ||
repository = "https://github.com/rimecraft-rs/rimecraft/" | ||
license = "AGPL-3.0-or-later" | ||
categories = [] | ||
|
@@ -14,7 +14,6 @@ maintenance = { status = "passively-maintained" } | |
[dependencies] | ||
rimecraft-registry = { path = "../../util/registry" } | ||
rimecraft-fmt = { path = "../../util/fmt" } | ||
rimecraft-freezer = { path = "../../util/freezer" } | ||
rimecraft-attachment = { path = "../../util/attachment" } | ||
rimecraft-serde-update = { path = "../../util/serde-update", optional = true } | ||
rimecraft-serde-humanreadctl = { path = "../../util/serde-humanreadctl", optional = true } | ||
|
@@ -23,7 +22,6 @@ rimecraft-nbt-ext = { path = "../../util/nbt-ext" } | |
serde = { version = "1.0", optional = true, features = ["derive"] } | ||
|
||
[features] | ||
default = ["serde"] | ||
serde = [ | ||
"dep:serde", | ||
"rimecraft-registry/serde", | ||
|
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
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