Skip to main content

BlockDef

Struct BlockDef 

Source
pub struct BlockDef {
    pub id: String,
    pub hardness: f32,
    pub resistance: f32,
    pub name: Option<String>,
    pub shape: Option<[f32; 6]>,
    pub light_level: u8,
    pub sound: Option<String>,
    pub requires_tool: bool,
    pub no_collision: bool,
    pub slipperiness: f32,
}
Expand description

A custom block to register; it also gets a matching block-item.

Fields§

§id: String§hardness: f32§resistance: f32§name: Option<String>§shape: Option<[f32; 6]>

Optional collision/outline box in pixel units (0–16): [x1,y1,z1,x2,y2,z2]. None = full cube.

§light_level: u8

Light emitted by this block (0 = none, 15 = max, like a torch).

§sound: Option<String>

Sound group id: "stone", "wood", "grass", "sand", "snow", "gravel", "metal", "glass", "wool", "nether_brick". None = stone (Minecraft default).

§requires_tool: bool

If true, the correct tool (from the block’s tags) is required for drops.

§no_collision: bool

If true, entities pass through this block (like flowers or torches).

§slipperiness: f32

Friction coefficient. 0.0 = default (0.6). Ice = 0.989.

Implementations§

Source§

impl BlockDef

Source

pub fn new(id: impl Into<String>) -> BlockDef

Source

pub fn strength(self, hardness: f32, resistance: f32) -> BlockDef

Mining hardness and blast resistance (defaults 1.5 / 6.0).

Source

pub fn name(self, name: impl Into<String>) -> BlockDef

Display name shown in-game.

Source

pub fn shape( self, x1: f32, y1: f32, z1: f32, x2: f32, y2: f32, z2: f32, ) -> BlockDef

Custom hitbox/outline in pixel units (0–16).

Source

pub fn light_level(self, level: u8) -> BlockDef

Emitted light level (0–15).

Source

pub fn sound(self, group: impl Into<String>) -> BlockDef

Sound group: "stone", "wood", "grass", "sand", "snow", "gravel", "metal", "glass", "wool", "nether_brick".

Source

pub fn requires_tool(self) -> BlockDef

Correct tool required for loot drops (equivalent to requiresTool()).

Source

pub fn no_collision(self) -> BlockDef

No physical collision — entities pass through (like flowers).

Source

pub fn slipperiness(self, value: f32) -> BlockDef

Friction (default 0.6). Set to 0.989 for ice-like slipperiness.

Trait Implementations§

Source§

impl Clone for BlockDef

Source§

fn clone(&self) -> BlockDef

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BlockDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.