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>) -> 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, _: [f32; 3], _: [f32; 3]) -> BlockDef
pub fn shape(self, _: [f32; 3], _: [f32; 3]) -> BlockDef
Custom hitbox/outline in pixel units (0–16): its lowest corner and its highest.
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: one of the game’s ("stone", "amethyst"…) or a
mod’s [SoundGroup] ("mymod:crystal").
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:
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) -> BlockDef
pub fn redstone_source(self) -> BlockDef
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) -> BlockDef
pub fn facing(self, ways: Facing, placement: Placement) -> BlockDef
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) -> BlockDef
pub fn waterlogged(self) -> BlockDef
Can stand in water.
Sourcepub fn property(self, name: &str, values: &[&str]) -> BlockDef
pub fn property(self, name: &str, values: &[&str]) -> BlockDef
A property of its own: values, the first the default.
Sourcepub fn powered(self, name: &str) -> BlockDef
pub fn powered(self, name: &str) -> BlockDef
Keeps yes/no property name on while it gets redstone power.
Sourcepub fn comparator(self, name: &str) -> BlockDef
pub fn comparator(self, name: &str) -> BlockDef
A comparator reads 15 from it while yes/no property name is on.
Sourcepub fn accepts_items(self) -> BlockDef
pub fn accepts_items(self) -> BlockDef
Hoppers and droppers can put items into it (on_item_insert).
pub fn inventory(self, id: impl Into<String>) -> BlockDef
Sourcepub fn no_occlusion(self) -> BlockDef
pub fn no_occlusion(self) -> BlockDef
Doesn’t hide the faces behind it or stop light (as glass).
Sourcepub fn kind(self, kind: &str) -> BlockDef
pub fn kind(self, kind: &str) -> BlockDef
One of the game’s kinds of block ("stairs", "door"…).
Sourcepub fn press_ticks(self, ticks: u32) -> BlockDef
pub fn press_ticks(self, ticks: u32) -> BlockDef
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<BlockDef>
fn decode(__yog_d: &mut Decoder<'_>) -> Option<BlockDef>
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<BlockDef>
fn unpack(__yog_u: &mut Unpacker<'_>) -> Option<BlockDef>
None if the bytes aren’t what
Schema::pack writes.Source§fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<BlockDef>
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<BlockDef>
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.Source§fn pack_list(items: &[Self], p: &mut Packer)
fn pack_list(items: &[Self], p: &mut Packer)
Source§fn encode_list(items: &[Self], w: &mut Writer)
fn encode_list(items: &[Self], w: &mut Writer)
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> 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,
Source§impl<T> Message for Twhere
T: Schema,
impl<T> Message for Twhere
T: Schema,
Source§fn from_bytes(bytes: &[u8]) -> Option<Self>
fn from_bytes(bytes: &[u8]) -> Option<Self>
None if it isn’t one.Source§fn with_bytes<R>(&self, f: impl FnOnce(&[u8]) -> R) -> R
fn with_bytes<R>(&self, f: impl FnOnce(&[u8]) -> R) -> R
f on the payload, packed in this thread’s reused buffers: nothing
allocated once they’ve grown to the thread’s messages.