Interface PlayerInventoryStorage
- All Superinterfaces:
InventoryStorage
,Storage<ItemVariant>
@Experimental
@Deprecated
@NonExtendable
public interface PlayerInventoryStorage
extends InventoryStorage
Deprecated.
Experimental feature, we reserve the right to remove or change it without further notice.
The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
A
Storage<ItemVariant>
implementation for a PlayerInventory
.
This is a specialized version of InventoryStorage
,
with an additional transactional wrapper for PlayerInventory.offerOrDrop(net.minecraft.item.ItemStack)
.
Note that this is a wrapper around all the slots of the player inventory.
This may cause direct insertion to insert arbitrary items into equipment slots or other unexpected behavior.
To prevent this, offerOrDrop(net.fabricmc.fabric.api.transfer.v1.item.ItemVariant, long, net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext)
is recommended for simple insertions.
InventoryStorage.getSlots()
can also be used and combined with CombinedStorage
to retrieve a wrapper around a specific range of slots.
-
Method Summary
Modifier and TypeMethodDescriptionstatic SingleSlotStorage<ItemVariant>
getCursorStorage(net.minecraft.screen.ScreenHandler screenHandler)
Deprecated.Return a wrapper around the cursor slot of a screen handler, i.e.static PlayerInventoryStorage
of(net.minecraft.entity.player.PlayerEntity player)
Deprecated.Return an instance for the passed player's inventory.static PlayerInventoryStorage
of(net.minecraft.entity.player.PlayerInventory playerInventory)
Deprecated.Return an instance for the passed player inventory.void
offerOrDrop(ItemVariant variant, long amount, TransactionContext transaction)
Deprecated.Add items to the inventory if possible, and drop any leftover items in the world, similar toPlayerInventory.offerOrDrop(net.minecraft.item.ItemStack)
Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.item.InventoryStorage
getSlots
Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.Storage
exactView, extract, getVersion, insert, iterable, iterator, supportsExtraction, supportsInsertion
-
Method Details
-
of
Deprecated.Return an instance for the passed player's inventory. -
of
Deprecated.Return an instance for the passed player inventory. -
getCursorStorage
static SingleSlotStorage<ItemVariant> getCursorStorage(net.minecraft.screen.ScreenHandler screenHandler)Deprecated.Return a wrapper around the cursor slot of a screen handler, i.e. the stack that can be manipulated withScreenHandler.getCursorStack()
andScreenHandler.setCursorStack(net.minecraft.item.ItemStack)
. -
offerOrDrop
Deprecated.Add items to the inventory if possible, and drop any leftover items in the world, similar toPlayerInventory.offerOrDrop(net.minecraft.item.ItemStack)
Note: This function has full transaction support, and will not actually drop the items until the outermost transaction is committed.
- Parameters:
variant
- The variant to insert.amount
- How many of the variant to insert.transaction
- The transaction this operation is part of.
-