Skip to main content

Block

Struct Block 

#[non_exhaustive]
pub struct Block {
Show 23 fields pub id: String, pub template: String, pub properties: BlockProperties, pub shapes: Option<BlockShapes>, pub collision_shapes: Option<BlockShapes>, pub outline_context_shapes: BTreeMap<ShapeEntityKind, BlockShapes>, pub collision_context_shapes: BTreeMap<ShapeEntityKind, BlockShapes>, pub interaction_shapes: Option<BlockShapes>, pub state_properties: BTreeMap<String, BlockStateProperty>, pub default_state: BTreeMap<String, String>, pub item: bool, pub open_sound: Option<String>, pub close_sound: Option<String>, pub block_item: Option<String>, pub pick_item: Option<String>, pub components: Vec<(String, Option<Tag>)>, pub connects_to: Option<String>, pub thickness: Option<f32>, pub wood_type: Option<String>, pub wall_block: Option<String>, pub sign_text_color: Option<String>, pub sign_text_glow: Option<bool>, pub base_block: Option<String>,
}
Expand description

An unvalidated draft; Content::declare validates it at load. Refused drafts are reported by the content admission path as native blocks and items of <namespace>: <reason>, without admitting part of that namespace.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: String

<mod id>:<path>.

§template: String

The vanilla block it copies, minecraft:<path>.

§properties: BlockProperties

properties.

§shapes: Option<BlockShapes>

shapes.

§collision_shapes: Option<BlockShapes>

collision shapes.

§outline_context_shapes: BTreeMap<ShapeEntityKind, BlockShapes>

Outline overrides for actual entity queries; omitted kinds use the default.

§collision_context_shapes: BTreeMap<ShapeEntityKind, BlockShapes>

Collision overrides for actual entity queries; omitted kinds use the default.

§interaction_shapes: Option<BlockShapes>

Ray-face override, without replacing the outline hit point or creating a hit.

§state_properties: BTreeMap<String, BlockStateProperty>

State properties of its own, which its template does not have.

§default_state: BTreeMap<String, String>

State properties overlaid on the template default.

§item: bool

Also add a block item with the same id.

§open_sound: Option<String>

The sound event a fence gate plays opening, instead of its wood’s (WoodType.fenceGateOpen); needs a *_fence_gate template.

§close_sound: Option<String>

The sound event a fence gate plays closing (WoodType.fenceGateClose).

§block_item: Option<String>

The item this block is, for pick-block and Block.asItem, when it is not a block item of its own: an item of this mod or a vanilla one, checked to exist when the content loads. Needs item false.

§pick_item: Option<String>

The item pick-block takes from this block (getCloneItemStack), when it is not the block’s item: a mature crop picks its seed. An item of this mod or a vanilla one, checked to exist when the content loads. Absent is the block’s item.

§components: Vec<(String, Option<Tag>)>

Its item’s ordered component patch: Some(tag) sets a component, None removes it. Component names do not include the removal prefix !.

§connects_to: Option<String>

A connecting block (template minecraft:chorus_plant, a PipeBlock without the chorus plant’s rules): the block tag, without #, whose blocks it joins besides itself (a cable’s machines).

§thickness: Option<f32>

A connecting block’s width in pixels (2 to 14): its shapes, the chorus plant’s (10) when unset.

§wood_type: Option<String>

A sign’s WoodType (template a vanilla sign), which names its editor’s background: <namespace>:<path> a mod’s texture, a bare name vanilla’s. The template’s when unset.

§wall_block: Option<String>

The block a standing or ceiling sign’s item places on a wall (StandingAndWallBlockItem.wallBlock): one of this mod’s blocks, whose template is the matching wall sign and which has no item. The template’s when unset.

§sign_text_color: Option<String>

A sign’s new text colour (SignBlockEntity.createDefaultSignText): a DyeColor name, black when unset. Applies to a sign when it is placed, front and back.

§sign_text_glow: Option<bool>

Whether a new sign’s text glows, false when unset.

§base_block: Option<String>

The block farmland turns into; the template’s base when unset.

Implementations§

§

impl Block

pub fn with_item(self, item: bool) -> Block

Request a block item with the same identifier.

pub fn new(id: impl Into<String>, template: impl Into<String>) -> Block

Start an unvalidated declaration request; content admission checks both identifiers.

Trait Implementations§

§

impl Clone for Block

§

fn clone(&self) -> Block

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Block

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Block

§

fn default() -> Block

Returns the “default value” for a type. Read more
§

impl PartialEq for Block

§

fn eq(&self, other: &Block) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl StructuralPartialEq for Block

§

impl Wire for Block

§

const MIN: usize

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take(input: &mut Reader<'_>) -> Result<Block, WireError>

Decodes one value, leaving any following bytes for the caller.

Auto Trait Implementations§

§

impl Freeze for Block

§

impl RefUnwindSafe for Block

§

impl Send for Block

§

impl Sync for Block

§

impl Unpin for Block

§

impl UnsafeUnpin for Block

§

impl UnwindSafe for Block

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Put for T
where T: Wire,

§

fn put_to(&self, out: &mut Writer)

Writes it.
§

impl<T> Record for T
where T: Wire,

§

fn encode(&self, out: &mut Writer)

Writes the argument into a hook call.
§

fn apply(&mut self, bytes: &[u8]) -> Result<(), WireError>

Applies one complete reply, refusing malformed or trailing bytes atomically.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.