Skip to main content

ContainerBuilder

Struct ContainerBuilder 

Source
pub struct ContainerBuilder { /* private fields */ }
Expand description

Fluent builder for Container configurations.

The builder has no side effects; call .build() to produce a Container value that can be stored, cloned, and opened for any player via ctx.containers().open(&container).

Implementations§

Source§

impl ContainerBuilder

Source

pub fn new() -> Self

Creates a builder with sensible defaults (Generic9x3, empty title, Virtual, no slots).

Source

pub fn inventory_type(self, t: InventoryType) -> Self

Sets the inventory type for the container window.

Source

pub fn title(self, title: impl Into<String>) -> Self

Sets the window title shown to the player.

Source

pub fn backed_by(self, x: i32, y: i32, z: i32) -> Self

Backs the container with a block entity at the given position.

If no initial slots are provided via slots(), the server reads the slots from the block entity at this position.

Source

pub fn slots(self, slots: Vec<Slot>) -> Self

Pre-fills the container with the given slot contents.

If the vector length does not match InventoryType::slot_count(), it will be truncated or padded with empty slots on build().

Source

pub fn build(self) -> Container

Finalizes the builder into a Container value.

Pads or truncates initial_slots to match inventory_type.slot_count().

Trait Implementations§

Source§

impl Default for ContainerBuilder

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> 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.

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.