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
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).
PlayerHand
What a player holds in hand (forPlayerInteraction).
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
The player’s open menu.
BlockEntity
Slot slot of the block entity at pos as side reaches it, through its ITEMS
handler (forHandlerIndex).
Fields
ItemEntity
The stack of item entity id in the level in place.
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).
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.
Nested
Slot slot of the item at parent, through its ITEM_ITEMS handler: a backpack in a
backpack.
Fields
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.
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.
Implementations§
§impl ItemPlace
impl ItemPlace
pub fn stack(&self, host: &mut dyn ServerHost) -> Option<ItemStack>
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>
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
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
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
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
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
impl ItemPlace
pub fn capability<T>(
&self,
host: &mut dyn ServerHost,
key: &ItemCapabilityKey<T>,
) -> Option<Capability<T>>where
T: 'static + ?Sized,
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.