pub struct CrafterInventory<'mc>(/* private fields */);Implementations§
Source§impl<'mc> CrafterInventory<'mc>
impl<'mc> CrafterInventory<'mc>
Sourcepub fn max_stack_size(&self) -> Result<i32, Box<dyn Error>>
pub fn max_stack_size(&self) -> Result<i32, Box<dyn Error>>
Returns the maximum stack size for an ItemStack in this inventory.
Sourcepub fn set_max_stack_size(&self, size: i32) -> Result<(), Box<dyn Error>>
pub fn set_max_stack_size(&self, size: i32) -> Result<(), Box<dyn Error>>
This method allows you to change the maximum stack size for an inventory.
Caveats:
- Not all inventories respect this value.
- Stacks larger than 127 may be clipped when the world is saved.
- This value is not guaranteed to be preserved; be sure to set it before every time you want to set a slot over the max stack size.
- Stacks larger than the default max size for this type of inventory may not display correctly in the client.
Sourcepub fn get_item(
&self,
index: i32,
) -> Result<Option<ItemStack<'mc>>, Box<dyn Error>>
pub fn get_item( &self, index: i32, ) -> Result<Option<ItemStack<'mc>>, Box<dyn Error>>
Returns the ItemStack found in the slot at the given index
Sourcepub fn set_item(
&self,
index: i32,
item: Option<impl Into<ItemStack<'mc>>>,
) -> Result<(), Box<dyn Error>>
pub fn set_item( &self, index: i32, item: Option<impl Into<ItemStack<'mc>>>, ) -> Result<(), Box<dyn Error>>
Stores the ItemStack at the given index of the inventory.
Sourcepub fn add_item(
&self,
items: impl Into<ItemStack<'mc>>,
) -> Result<JavaHashMap<'mc>, Box<dyn Error>>
pub fn add_item( &self, items: impl Into<ItemStack<'mc>>, ) -> Result<JavaHashMap<'mc>, Box<dyn Error>>
Stores the given ItemStacks in the inventory. This will try to fill existing stacks and empty slots as well as it can.
The returned HashMap contains what it couldn’t store, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all items are stored, it will return an empty HashMap.
If you pass in ItemStacks which exceed the maximum stack size for the Material, first they will be added to partial stacks where Material.getMaxStackSize() is not exceeded, up to Material.getMaxStackSize(). When there are no partial stacks left stacks will be split on Inventory.getMaxStackSize() allowing you to exceed the maximum stack size for that material.
It is known that in some implementations this method will also set the inputted argument amount to the number of that item not placed in slots.
Sourcepub fn remove_item(
&self,
items: impl Into<ItemStack<'mc>>,
) -> Result<JavaHashMap<'mc>, Box<dyn Error>>
pub fn remove_item( &self, items: impl Into<ItemStack<'mc>>, ) -> Result<JavaHashMap<'mc>, Box<dyn Error>>
Removes the given ItemStacks from the inventory.
It will try to remove ‘as much as possible’ from the types and amounts you give as arguments.
The returned HashMap contains what it couldn’t remove, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all the given ItemStacks are removed, it will return an empty HashMap.
It is known that in some implementations this method will also set the inputted argument amount to the number of that item not removed from slots.
Sourcepub fn contents(&self) -> Result<ItemStack<'mc>, Box<dyn Error>>
pub fn contents(&self) -> Result<ItemStack<'mc>, Box<dyn Error>>
Returns all ItemStacks from the inventory
Sourcepub fn set_contents(
&self,
items: impl Into<ItemStack<'mc>>,
) -> Result<(), Box<dyn Error>>
pub fn set_contents( &self, items: impl Into<ItemStack<'mc>>, ) -> Result<(), Box<dyn Error>>
Completely replaces the inventory’s contents. Removes all existing contents and replaces it with the ItemStacks given in the array.
Sourcepub fn storage_contents(&self) -> Result<ItemStack<'mc>, Box<dyn Error>>
pub fn storage_contents(&self) -> Result<ItemStack<'mc>, Box<dyn Error>>
Return the contents from the section of the inventory where items can reasonably be expected to be stored. In most cases this will represent the entire inventory, but in some cases it may exclude armor or result slots.
It is these contents which will be used for add / contains / remove methods which look for a specific stack.
Sourcepub fn set_storage_contents(
&self,
items: impl Into<ItemStack<'mc>>,
) -> Result<(), Box<dyn Error>>
pub fn set_storage_contents( &self, items: impl Into<ItemStack<'mc>>, ) -> Result<(), Box<dyn Error>>
Put the given ItemStacks into the storage slots
Sourcepub fn contains(
&self,
material: impl Into<Material<'mc>>,
amount: Option<i32>,
) -> Result<bool, Box<dyn Error>>
pub fn contains( &self, material: impl Into<Material<'mc>>, amount: Option<i32>, ) -> Result<bool, Box<dyn Error>>
Checks if the inventory contains any ItemStacks with the given material, adding to at least the minimum amount specified.
Sourcepub fn contains_at_least(
&self,
item: impl Into<ItemStack<'mc>>,
amount: i32,
) -> Result<bool, Box<dyn Error>>
pub fn contains_at_least( &self, item: impl Into<ItemStack<'mc>>, amount: i32, ) -> Result<bool, Box<dyn Error>>
Checks if the inventory contains ItemStacks matching the given ItemStack whose amounts sum to at least the minimum amount specified.
Sourcepub fn all(
&self,
item: impl Into<ItemStack<'mc>>,
) -> Result<JavaHashMap<'mc>, Box<dyn Error>>
pub fn all( &self, item: impl Into<ItemStack<'mc>>, ) -> Result<JavaHashMap<'mc>, Box<dyn Error>>
Finds all slots in the inventory containing any ItemStacks with the given ItemStack. This will only match slots if both the type and the amount of the stack match
The HashMap contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack with the given Material is found, an empty map is returned.
Sourcepub fn first(
&self,
item: impl Into<ItemStack<'mc>>,
) -> Result<i32, Box<dyn Error>>
pub fn first( &self, item: impl Into<ItemStack<'mc>>, ) -> Result<i32, Box<dyn Error>>
Returns the first slot in the inventory containing an ItemStack with the given stack. This will only match a slot if both the type and the amount of the stack match
Sourcepub fn is_empty(&self) -> Result<bool, Box<dyn Error>>
pub fn is_empty(&self) -> Result<bool, Box<dyn Error>>
Check whether or not this inventory is empty. An inventory is considered to be empty if there are no ItemStacks in any slot of this inventory.
Sourcepub fn remove(
&self,
item: impl Into<ItemStack<'mc>>,
) -> Result<(), Box<dyn Error>>
pub fn remove( &self, item: impl Into<ItemStack<'mc>>, ) -> Result<(), Box<dyn Error>>
Removes all stacks in the inventory matching the given stack.
This will only match a slot if both the type and the amount of the stack match
Sourcepub fn clear(&self, index: Option<i32>) -> Result<(), Box<dyn Error>>
pub fn clear(&self, index: Option<i32>) -> Result<(), Box<dyn Error>>
Clears out a particular slot in the index.
Sourcepub fn viewers(&self) -> Result<Vec<HumanEntity<'mc>>, Box<dyn Error>>
pub fn viewers(&self) -> Result<Vec<HumanEntity<'mc>>, Box<dyn Error>>
Gets a list of players viewing the inventory. Note that a player is considered to be viewing their own inventory and internal crafting screen even when said inventory is not open. They will normally be considered to be viewing their inventory even when they have a different inventory screen open, but it’s possible for customized inventory screens to exclude the viewer’s inventory, so this should never be assumed to be non-empty.
Sourcepub fn get_type(&self) -> Result<InventoryType<'mc>, Box<dyn Error>>
pub fn get_type(&self) -> Result<InventoryType<'mc>, Box<dyn Error>>
Returns what type of inventory this is.
Sourcepub fn holder(&self) -> Result<Option<InventoryHolder<'mc>>, Box<dyn Error>>
pub fn holder(&self) -> Result<Option<InventoryHolder<'mc>>, Box<dyn Error>>
Gets the block or entity belonging to the open inventory
pub fn iterator(&self) -> Result<JavaListIterator<'mc>, Box<dyn Error>>
Sourcepub fn location(&self) -> Result<Option<Location<'mc>>, Box<dyn Error>>
pub fn location(&self) -> Result<Option<Location<'mc>>, Box<dyn Error>>
Get the location of the block or entity which corresponds to this inventory. May return null if this container was custom created or is a virtual / subcontainer.
pub fn instance_of(&self, other: impl Into<String>) -> Result<bool, Error>
Trait Implementations§
Source§impl<'mc> Into<Inventory<'mc>> for CrafterInventory<'mc>
impl<'mc> Into<Inventory<'mc>> for CrafterInventory<'mc>
Source§impl<'mc> JNIInstantiatable<'mc> for CrafterInventory<'mc>
impl<'mc> JNIInstantiatable<'mc> for CrafterInventory<'mc>
Source§impl<'mc> JNIRaw<'mc> for CrafterInventory<'mc>
impl<'mc> JNIRaw<'mc> for CrafterInventory<'mc>
fn jni_ref(&self) -> SharedJNIEnv<'mc>
fn jni_object(&self) -> JObject<'mc>
Auto Trait Implementations§
impl<'mc> !Freeze for CrafterInventory<'mc>
impl<'mc> !RefUnwindSafe for CrafterInventory<'mc>
impl<'mc> !Send for CrafterInventory<'mc>
impl<'mc> !Sync for CrafterInventory<'mc>
impl<'mc> Unpin for CrafterInventory<'mc>
impl<'mc> UnwindSafe for CrafterInventory<'mc>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more