pub struct BlockDef {Show 13 fields
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>,
pub inventory_id: Option<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.
inventory_id: Option<String>Id of a YogInventoryDef this block is backed by — None = plain
block (default). See yog_inventory’s DESIGN.md.
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BlockDef
impl<'de> Deserialize<'de> for BlockDef
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockDef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockDef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for BlockDef
impl Serialize for BlockDef
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for BlockDef
impl RefUnwindSafe for BlockDef
impl Send for BlockDef
impl Sync for BlockDef
impl Unpin for BlockDef
impl UnsafeUnpin for BlockDef
impl UnwindSafe for BlockDef
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.