tutorial:transfer-api_fluid-containing-items
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:transfer-api_fluid-containing-items [2022/02/11 18:16] – technici4n | tutorial:transfer-api_fluid-containing-items [2022/02/11 18:40] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 58: | Line 58: | ||
| A word of caution: don't use '' | A word of caution: don't use '' | ||
| + | |||
| + | ==== The API in action ==== | ||
| + | An example to understand what is going on: how to query a storage for the main hand of a player, and insert 1 bucket of water into it: | ||
| + | <code java> | ||
| + | PlayerEntity player; | ||
| + | |||
| + | // Build the ContainerItemContext. | ||
| + | ContainerItemContext handContext = ContainerItemContext.ofPlayerHand(player, | ||
| + | // Use it to query a fluid storage. | ||
| + | Storage< | ||
| + | if (handStorage != null) { | ||
| + | // Use the storage: any usual Storage< | ||
| + | try (Transaction transaction = Transaction.openOuter()) { | ||
| + | handStorage.insert(FluidVariant.of(Fluids.WATER), | ||
| + | transaction.commit(); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | TODO: | ||
| + | - filling an item, example from TR | ||
| + | - using the existing base implementations for items | ||
tutorial/transfer-api_fluid-containing-items.1644603403.txt.gz · Last modified: 2022/02/11 18:16 by technici4n