pub struct BlockDef {Show 28 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>,
pub redstone_source: bool,
pub facing: Option<Facing>,
pub placement: Placement,
pub attach: bool,
pub waterlogged: bool,
pub properties: Vec<BlockProperty>,
pub powered: Option<String>,
pub comparator: Option<String>,
pub accepts_items: bool,
pub no_occlusion: bool,
pub kind: String,
pub base: Option<String>,
pub set: Option<String>,
pub press_ticks: u32,
pub mobs_only: bool,
}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>Its [SoundGroup]: one of the game’s by name ("stone",
"amethyst", "copper" — [SoundGroup::built_in]) or a mod’s
("mymod:crystal"). 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.
redstone_source: boolGives off redstone power — how much, per position, the mod sets with
block::set_redstone_output.
facing: Option<Facing>How it turns when placed (a facing property); None: it doesn’t.
placement: PlacementWhich way it turns when placed.
attach: boolIt hangs on a floor, wall or ceiling, as a button (a face
property and a horizontal facing).
waterlogged: boolIt can stand in water (a waterlogged property).
properties: Vec<BlockProperty>Properties of its own.
powered: Option<String>A yes/no property the block keeps on while it gets redstone power.
comparator: Option<String>A yes/no property a comparator reads 15 from while it’s on.
accepts_items: boolHoppers and droppers can put items into it (on_item_insert).
no_occlusion: boolIt doesn’t hide the faces behind it or stop light (as glass, a door).
kind: StringOne of the game’s kinds of block it is (stairs, slab, door,
trapdoor, button, pressure_plate, fence, fence_gate): the
host makes it of the game’s class, with that class’s states; "": a
block of Yog’s own.
base: Option<String>The block a kind is made from (stairs act as it).
set: Option<String>A kind’s set — a registered block set by name (oak, iron…; a
fence gate’s wood type); None: oak.
press_ticks: u32How long a button stays pressed, ticks.
mobs_only: boolOnly living things set off a button or a pressure plate (not items or arrows).
Implementations§
Source§impl BlockDef
impl BlockDef
pub fn new(id: impl Into<String>) -> Self
Sourcepub fn strength(self, hardness: f32, resistance: f32) -> Self
pub fn strength(self, hardness: f32, resistance: f32) -> Self
Mining hardness and blast resistance (defaults 1.5 / 6.0).
Sourcepub fn shape(self, [x1, y1, z1]: [f32; 3], [x2, y2, z2]: [f32; 3]) -> Self
pub fn shape(self, [x1, y1, z1]: [f32; 3], [x2, y2, z2]: [f32; 3]) -> Self
Custom hitbox/outline in pixel units (0–16): its lowest corner and its highest.
Sourcepub fn light_level(self, level: u8) -> Self
pub fn light_level(self, level: u8) -> Self
Emitted light level (0–15).
Sourcepub fn sound(self, group: impl Into<String>) -> Self
pub fn sound(self, group: impl Into<String>) -> Self
Sound group: one of the game’s ("stone", "amethyst"…) or a
mod’s [SoundGroup] ("mymod:crystal").
Sourcepub fn requires_tool(self) -> Self
pub fn requires_tool(self) -> Self
Correct tool required for loot drops (equivalent to requiresTool()).
Sourcepub fn no_collision(self) -> Self
pub fn no_collision(self) -> Self
No physical collision — entities pass through (like flowers).
Sourcepub fn slipperiness(self, value: f32) -> Self
pub fn slipperiness(self, value: f32) -> Self
Friction (default 0.6). Set to 0.989 for ice-like slipperiness.
Sourcepub fn connects_to_neighbors(self) -> Self
pub fn connects_to_neighbors(self) -> Self
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]) -> Self
pub fn connect_groups(self, groups: &[&str]) -> Self
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:
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.
Sourcepub fn redstone_source(self) -> Self
pub fn redstone_source(self) -> Self
Back this block with a real Container/Menu inventory screen, whose
shape/layout was registered separately via Registry::register_inventory
— see yog_inventory::InventoryDef. id is that def’s id.
A redstone power source: what each placed block gives off is set
with block::set_redstone_output (0 until then).
Sourcepub fn facing(self, ways: Facing, placement: Placement) -> Self
pub fn facing(self, ways: Facing, placement: Placement) -> Self
Turns when placed: "horizontal" or "all" ways, its front (the
model’s north side) "toward" the placer or "away" (the way they look).
Sourcepub fn waterlogged(self) -> Self
pub fn waterlogged(self) -> Self
Can stand in water.
Sourcepub fn property(self, name: &str, values: &[&str]) -> Self
pub fn property(self, name: &str, values: &[&str]) -> Self
A property of its own: values, the first the default.
Sourcepub fn powered(self, name: &str) -> Self
pub fn powered(self, name: &str) -> Self
Keeps yes/no property name on while it gets redstone power.
Sourcepub fn comparator(self, name: &str) -> Self
pub fn comparator(self, name: &str) -> Self
A comparator reads 15 from it while yes/no property name is on.
Sourcepub fn accepts_items(self) -> Self
pub fn accepts_items(self) -> Self
Hoppers and droppers can put items into it (on_item_insert).
pub fn inventory(self, id: impl Into<String>) -> Self
Sourcepub fn no_occlusion(self) -> Self
pub fn no_occlusion(self) -> Self
Doesn’t hide the faces behind it or stop light (as glass).
Sourcepub fn press_ticks(self, ticks: u32) -> Self
pub fn press_ticks(self, ticks: u32) -> Self
How long a button stays pressed, ticks (30 by default).
Trait Implementations§
Source§impl Schema for BlockDef
impl Schema for BlockDef
Source§fn encode(&self, __yog_w: &mut Writer)
fn encode(&self, __yog_w: &mut Writer)
Schema::write’s
value encoded, unless the type knows better (derived ones do).Source§fn decode(__yog_d: &mut Decoder<'_>) -> Option<Self>
fn decode(__yog_d: &mut Decoder<'_>) -> Option<Self>
None when it isn’t
what Schema::encode writes — then read_bytes reads the slow
way, which says what’s wrong. Through a value unless the type knows
better (derived ones do).Source§fn pack(&self, __yog_p: &mut Packer)
fn pack(&self, __yog_p: &mut Packer)
crate::frame): its binary form as
bytes, unless the type packs itself (derived ones and plain types do).Source§fn unpack(__yog_u: &mut Unpacker<'_>) -> Option<Self>
fn unpack(__yog_u: &mut Unpacker<'_>) -> Option<Self>
None if the bytes aren’t what
Schema::pack writes.Source§fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
v. Problems go to cx at its current path; None when the
value couldn’t be read (the problem is in cx).Source§fn absent() -> Option<Self>
fn absent() -> Option<Self>
None: the field is required.