Skip to main content

ItemPlace

Enum ItemPlace 

#[non_exhaustive]
pub enum ItemPlace { PlayerSlot { player: u128, slot: i32, }, PlayerHand { player: u128, hand: Hand, }, PlayerCursor { menu: MenuRef, }, BlockEntity { level: LevelRef, pos: [i32; 3], side: Option<Direction>, slot: usize, }, ItemEntity { id: u32, }, EntitySlot { entity: u32, slot: usize, }, Equipment { entity: u32, slot: EquipmentSlot, }, Nested { parent: Box<ItemPlace>, slot: usize, }, MenuSlot { menu: MenuRef, slot: usize, }, Mod { provider: &'static str, key: u64, }, }
Expand description

Where a stack lives.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

PlayerSlot

Slot slot of a player’s inventory, by native_inventory_tick’s numbers: 0..36 (0..9 the hotbar), the armour 100..=103 (feet to head), the off hand -106 (ItemAccess.forPlayerSlot).

Fields

§player: u128

The player’s UUID.

§slot: i32

The slot number, as listed above.

§

PlayerHand

What a player holds in hand (forPlayerInteraction).

Fields

§player: u128

The player’s UUID.

§hand: Hand

Which hand.

§

PlayerCursor

The stack on the cursor of a player’s open menu, menu (forPlayerCursor): nothing once the menu is closed, replaced or its player gone.

Fields

§menu: MenuRef

The player’s open menu.

§

BlockEntity

Slot slot of the block entity at pos as side reaches it, through its ITEMS handler (forHandlerIndex).

Fields

§level: LevelRef

The level the block entity is in.

§pos: [i32; 3]

The block entity’s position.

§side: Option<Direction>

The face the handler is reached from; None for no particular side.

§slot: usize

The slot’s index in the handler.

§

ItemEntity

The stack of item entity id in the level in place.

Fields

§id: u32

The item entity’s network id.

§

EntitySlot

Slot slot of the inventory of entity entity in the level in place: a chest or hopper minecart’s, a chest boat’s, or a chested donkey’s, mule’s or llama’s (Capabilities.Item.ENTITY through forHandlerIndex).

Fields

§entity: u32

The entity’s network id.

§slot: usize

The slot’s index in the entity’s inventory.

§

Equipment

Slot slot of living entity entity’s equipment (NeoForge’s LivingEntityEquipmentWrapper through Capabilities.Item.ENTITY), reached through ENTITY_ITEMS. Its write is the equipment write LivingRef::set_equipment makes, so the equip and unequip game event, sound and attribute updates are the same, and a transaction that aborts puts it back.

Fields

§entity: u32

The entity’s network id.

§slot: EquipmentSlot

The equipment slot.

§

Nested

Slot slot of the item at parent, through its ITEM_ITEMS handler: a backpack in a backpack.

Fields

§parent: Box<ItemPlace>

The place of the stack that holds the container.

§slot: usize

The slot’s index inside that stack’s container.

§

MenuSlot

Slot slot of a player’s open menu, menu, a fork addition (NeoForge 26.3 has no ItemAccess for a menu slot): the storage the slot shows (MenuRef::slot_backing), its own slot only, under the slot’s own rules first (MenuRef::slot_holds, MenuRef::slot_gives). Nothing where the menu is closed, replaced or its player gone; nothing goes into or out of the crafting result.

Fields

§menu: MenuRef

The open menu.

§slot: usize

The slot’s index in that menu.

§

Mod

A place a mod keeps, such as an accessory slot: read and written by the PlaceProvider it registered as provider, which alone knows what key means.

Fields

§provider: &'static str

The provider’s registered name.

§key: u64

The provider’s own key for the place.

Implementations§

§

impl ItemPlace

pub fn stack(&self, host: &mut dyn ServerHost) -> Option<ItemStack>

The stack here, if any (getResource and getAmount).

pub fn resource(&self, host: &mut dyn ServerHost) -> Option<ItemResource>

What is here, without its count (ItemAccess.getResource).

pub fn amount(&self, host: &mut dyn ServerHost) -> u32

How many are here (ItemAccess.getAmount).

pub fn insert( &self, host: &mut dyn ServerHost, tx: &Transaction, resource: &ItemResource, amount: u32, ) -> u32

Puts up to amount of resource here, in transaction tx: how much went (ItemAccess.insert). What doesn’t stack with what is here, or doesn’t fit, goes where vanilla puts an item split off it: a player’s into their inventory, else dropped at the root commit (a creative player’s hand takes anything, and gives them one if they have none, as forInfiniteMaterials); an item entity’s dropped beside it at the root commit; a block entity’s, an entity’s or an item’s slot’s into that container’s other slots (forHandlerIndex); a mod’s place’s where its PlaceProvider puts it.

pub fn extract( &self, host: &mut dyn ServerHost, tx: &Transaction, resource: &ItemResource, amount: u32, ) -> u32

Takes up to amount of resource from here, in transaction tx: how much came (ItemAccess.extract). A creative player’s hand gives without losing any.

pub fn exchange( &self, host: &mut dyn ServerHost, tx: &Transaction, resource: &ItemResource, amount: u32, ) -> u32

Takes amount of what is here and puts as many of resource in their place (ItemAccess.exchange): from a bigger stack, they go where insert puts what doesn’t stack, as vanilla’s ItemUtils.createFilledResult puts a filled bucket. In a transaction of its own, nested in tx: all of it, or nothing and 0. Inside an item that shares its place with others like it, it’s done in one of them: that one splits off, changed, and the others stay as they were.

§

impl ItemPlace

pub fn capability<T>( &self, host: &mut dyn ServerHost, key: &ItemCapabilityKey<T>, ) -> Option<Capability<T>>
where T: 'static + ?Sized,

key‘s handler for the item here (ItemAccess.getCapability): the first provider to answer, of those mods registered for its item before_game, the game’s own, and the mods’ others, each in registration order. Disabled mods’ providers are skipped until their mod is re-enabled.

Trait Implementations§

§

impl Clone for ItemPlace

§

fn clone(&self) -> ItemPlace

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 ItemPlace

§

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

Formats the value using the given formatter. Read more
§

impl Eq for ItemPlace

§

impl PartialEq for ItemPlace

§

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

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

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

Inequality operator !=. Read more
§

impl StructuralPartialEq for ItemPlace

§

impl Wire for ItemPlace

§

const MIN: usize = 4

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

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

Encodes this value, recording failures on the writer.
§

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

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

fn put_owned(self, out: &mut Writer)

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

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