pub struct InventoryDef {
pub id: String,
pub slot_count: usize,
pub layout: Vec<SlotLayout>,
pub include_player_inventory: bool,
pub player_inv_offset: (f32, f32),
pub background_texture: Option<String>,
pub title: String,
}Expand description
Describes one inventory-backed screen: how many slots a mod block has, where they sit, whether the player’s own inventory is appended below, and which background texture to draw (vanilla default, or a mod’s own).
Fields§
§id: String§slot_count: usize§layout: Vec<SlotLayout>Per-slot pixel positions. Empty = auto-generate a default grid (see
InventoryDef::default_grid).
include_player_inventory: boolAppends the player’s main inventory (3×9) + hotbar (9) below the custom slots — no armor, no offhand. Native vanilla slot rendering.
player_inv_offset: (f32, f32)§background_texture: Option<String>None = default vanilla-style panel texture.
title: StringImplementations§
Source§impl InventoryDef
impl InventoryDef
pub fn new(id: impl Into<String>, slot_count: usize) -> InventoryDef
Sourcepub fn layout(self, layout: Vec<SlotLayout>) -> InventoryDef
pub fn layout(self, layout: Vec<SlotLayout>) -> InventoryDef
Explicit per-slot pixel positions, overriding the default grid.
Sourcepub fn layout_from_json(self, json: &str) -> InventoryDef
pub fn layout_from_json(self, json: &str) -> InventoryDef
Remap the slot grid from a JSON array of {"x":.., "y":..} objects —
one entry per slot, in slot-index order. Lets users/mod-packs override
the layout without recompiling. Invalid or short JSON is ignored
(falls back to whatever layout was set before, or the default grid).
Sourcepub fn include_player_inventory(self, v: bool) -> InventoryDef
pub fn include_player_inventory(self, v: bool) -> InventoryDef
Whether the player’s main inventory + hotbar (no armor/offhand) is
appended below the custom slots. Default: true.
pub fn player_inv_offset(self, x: f32, y: f32) -> InventoryDef
Sourcepub fn background_texture(self, path: impl Into<String>) -> InventoryDef
pub fn background_texture(self, path: impl Into<String>) -> InventoryDef
Custom background texture (resource path); None keeps the default
vanilla-style panel.
pub fn title(self, title: impl Into<String>) -> InventoryDef
Sourcepub fn resolved_layout(&self) -> Vec<SlotLayout>
pub fn resolved_layout(&self) -> Vec<SlotLayout>
Resolve the effective slot layout: the explicit one if set, otherwise a default vanilla-style grid (9 columns, wrapping downward, 18px spacing, starting at (8, 18) — same convention as vanilla containers).
Sourcepub fn default_grid(slot_count: usize) -> Vec<SlotLayout>
pub fn default_grid(slot_count: usize) -> Vec<SlotLayout>
Default vanilla-style grid: up to 9 columns, 18px spacing, starting at (8, 18) — leaves room for a title above, matches vanilla containers.
Trait Implementations§
Source§impl Clone for InventoryDef
impl Clone for InventoryDef
Source§fn clone(&self) -> InventoryDef
fn clone(&self) -> InventoryDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for InventoryDef
impl RefUnwindSafe for InventoryDef
impl Send for InventoryDef
impl Sync for InventoryDef
impl Unpin for InventoryDef
impl UnsafeUnpin for InventoryDef
impl UnwindSafe for InventoryDef
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,
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.