tutorial:transfer-api_storage
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:transfer-api_storage [2021/10/30 10:14] – technici4n | tutorial:transfer-api_storage [2021/10/30 10:25] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Fabric Transfer API: Understanding Storage<T> ===== | + | ===== Fabric Transfer API: Understanding Storage<FluidVariant> ===== |
//This article is part of a series on the Fabric Transfer API. [[tutorial: | //This article is part of a series on the Fabric Transfer API. [[tutorial: | ||
Line 92: | Line 92: | ||
if (view.isResourceBlank()) continue; // This means that the view contains no resource, represented by FluidVariant.blank(). | if (view.isResourceBlank()) continue; // This means that the view contains no resource, represented by FluidVariant.blank(). | ||
FluidVariant storedResource = view.getResource(); | FluidVariant storedResource = view.getResource(); | ||
+ | if (!filter.test(storedResource)) continue; // The filter rejected this resource, skip it. | ||
// If you want to extract any amount <= view.getAmount(), | // If you want to extract any amount <= view.getAmount(), | ||
Line 101: | Line 102: | ||
long extracted = view.extract(storedResource, | long extracted = view.extract(storedResource, | ||
if (extracted == amount) { | if (extracted == amount) { | ||
+ | totalExtracted += amount; | ||
nestedTransaction.commit(); | nestedTransaction.commit(); | ||
} else { | } else { | ||
- | // If we do nothing, the extraction is cancelled immediately when nestedTransaction is closed. | + | // If we do nothing, the extraction is cancelled immediately when nestedTransaction is closed |
} | } | ||
} | } | ||
Line 110: | Line 112: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ==== Conclusion ==== | ||
+ | You should now be able to use '' | ||
+ | |||
+ | You should also have a look at '' | ||
tutorial/transfer-api_storage.txt · Last modified: 2021/10/30 10:25 by 127.0.0.1