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: u8Light 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: boolIf true, the correct tool (from the block’s tags) is required for drops.
no_collision: boolIf true, entities pass through this block (like flowers or torches).
slipperiness: f32Friction coefficient. 0.0 = default (0.6). Ice = 0.989.
Implementations§
Source§impl BlockDef
impl BlockDef
pub fn new(id: impl Into<String>) -> BlockDef
Sourcepub fn strength(self, hardness: f32, resistance: f32) -> BlockDef
pub fn strength(self, hardness: f32, resistance: f32) -> BlockDef
Mining hardness and blast resistance (defaults 1.5 / 6.0).
Sourcepub fn shape(
self,
x1: f32,
y1: f32,
z1: f32,
x2: f32,
y2: f32,
z2: f32,
) -> BlockDef
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).
Sourcepub fn light_level(self, level: u8) -> BlockDef
pub fn light_level(self, level: u8) -> BlockDef
Emitted light level (0–15).
Sourcepub fn sound(self, group: impl Into<String>) -> BlockDef
pub fn sound(self, group: impl Into<String>) -> BlockDef
Sound group: "stone", "wood", "grass", "sand", "snow",
"gravel", "metal", "glass", "wool", "nether_brick".
Sourcepub fn requires_tool(self) -> BlockDef
pub fn requires_tool(self) -> BlockDef
Correct tool required for loot drops (equivalent to requiresTool()).
Sourcepub fn no_collision(self) -> BlockDef
pub fn no_collision(self) -> BlockDef
No physical collision — entities pass through (like flowers).
Sourcepub fn slipperiness(self, value: f32) -> BlockDef
pub fn slipperiness(self, value: f32) -> BlockDef
Friction (default 0.6). Set to 0.989 for ice-like slipperiness.