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,
pub connects: bool,
pub connect_groups: Vec<String>,
}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.
connects: boolIf true, this block dynamically grows arms toward neighbors it’s
compatible with (fence/pipe-style): the Java host tracks N/S/E/W/U/D
boolean blockstate properties, recomputed on placement and on
neighbor change, and grows the collision/outline shape from the
shape core box (or a default post) out to each connected side.
connect_groups: Vec<String>Connection compatibility tags (configured in code via
.connect_groups(&[...]) — see that method’s docs for how this
drives which blocks link up). Independent of connects: a block can
carry tags purely as a connection target (e.g. an ALU accepting a
Digital Cable) without dynamically growing its own shape.
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.
Sourcepub fn connects_to_neighbors(self) -> BlockDef
pub fn connects_to_neighbors(self) -> BlockDef
Dynamically grow arms toward compatible neighbors — fence/pipe-style.
“Compatible” means the neighbor also has a connect_groups tag in
common (set here, or via connect_groups alone on a static target
block). Call .connect_groups(&[...]) too, or this connects to
nothing. See the connects field doc.
Sourcepub fn connect_groups(self, groups: &[&str]) -> BlockDef
pub fn connect_groups(self, groups: &[&str]) -> BlockDef
Connection compatibility tags — two blocks link up (for
connects_to_neighbors arm growth, and as valid connection targets
generally) when their tag sets share at least one entry. Example: for
Yog-VLSI, analog_cable and redstone_port both carry "analog";
digital_cable carries "digital"; an ALU block carries both, so it
accepts either cable while a Redstone Port only accepts the analog one.