-
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.
feat(block): Block API and stone, grass block, dirt.
perf: use fastrand instead of rand to generate entity id.
- Loading branch information
Showing
11 changed files
with
294 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,22 @@ | ||
use crate::block::*; | ||
use crate::empty_block_state; | ||
pub(crate) const DIRT: &str = "minecraft:dirt"; | ||
pub struct Dirt { | ||
pub builder: BlockBuilder, | ||
} | ||
|
||
impl Dirt { | ||
pub(crate) fn new() -> Dirt { | ||
Dirt { | ||
builder: BlockBuilder::new::<DirtBlockState>(DIRT, BlockSettings::new().strength(0.6)), | ||
} | ||
} | ||
} | ||
|
||
impl Block for Dirt { | ||
fn get_builder(&self) -> &BlockBuilder { | ||
&self.builder | ||
} | ||
} | ||
|
||
empty_block_state!(DirtBlockState, DIRT); |
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,34 @@ | ||
use crate::block::{Block, BlockBuilder, BlockSettings, BlockState, BLOCKS_BY_NAME}; | ||
use crate::block_state; | ||
use serde_derive::Deserialize; | ||
|
||
pub(crate) const GRASS_BLOCK: &str = "minecraft:grass_block"; | ||
pub struct GrassBlock { | ||
pub builder: BlockBuilder, | ||
} | ||
impl GrassBlock { | ||
pub(crate) fn new() -> GrassBlock { | ||
GrassBlock { | ||
builder: BlockBuilder::new::<GrassBlockState>( | ||
GRASS_BLOCK, | ||
BlockSettings::new().strength(0.6), | ||
), | ||
} | ||
} | ||
} | ||
impl Block for GrassBlock { | ||
fn get_builder(&self) -> &BlockBuilder { | ||
&self.builder | ||
} | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct GrassBlockStateProperties { | ||
pub snowy: bool, | ||
} | ||
|
||
block_state! { | ||
GrassBlockState, | ||
GrassBlockStateProperties, | ||
GRASS_BLOCK | ||
} |
Oops, something went wrong.