User Tools

Site Tools


tutorial:transfer-api_item_storage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:transfer-api_item_storage [2022/02/04 17:33] – [Fabric Transfer API: Understanding Storage<ItemVariant>] technici4ntutorial:transfer-api_item_storage [2025/12/18 10:18] (current) – clarify why ItemStorage.of makes assumptions b0undarybreaker
Line 1: Line 1:
-====== Fabric Transfer API: item transfer with Storage<ItemVariant> ======+====== Fabric Transfer API: Item transfer with Storage<ItemVariant> ======
 //This article is part of a series on the Fabric Transfer API. [[tutorial:transfer-api|Link to the home page of the series]].// //This article is part of a series on the Fabric Transfer API. [[tutorial:transfer-api|Link to the home page of the series]].//
  
Line 70: Line 70:
 [[https://github.com/FabricMC/fabric/blob/1.18/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/item/PlayerInventoryStorage.java|PlayerInventoryStorage]] serves a similar purpose, but for player inventories. Make sure to read its documentation, it contains very useful functions such as ''offerOrDrop''. [[https://github.com/FabricMC/fabric/blob/1.18/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/item/PlayerInventoryStorage.java|PlayerInventoryStorage]] serves a similar purpose, but for player inventories. Make sure to read its documentation, it contains very useful functions such as ''offerOrDrop''.
  
-**A word of caution**: To be able to support transactions, ''ItemStorage.of'' assumes that each slot in the inventory is independent of other slots, and of other inventories. Do NOT use it if that is not the case for your inventory.+**A word of caution**: To be able to support transactions, ''ItemStorage.of'' assumes that each slot in the inventory is independent of other slots, and of other inventories. Do NOT use it if that is not the case for your inventory - if you do, there could be side effects that get left behind when a transaction is reverted.
  
 ===== How to implement Storage<ItemVariant> ===== ===== How to implement Storage<ItemVariant> =====
tutorial/transfer-api_item_storage.1643996011.txt.gz · Last modified: 2022/02/04 17:33 by technici4n