tutorial:transfer-api_fluid_implementation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:transfer-api_fluid_implementation [2022/02/02 20:27] – [A more involved example] technici4n | tutorial:transfer-api_fluid_implementation [2022/02/02 20:28] (current) – [Internal tanks] technici4n | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Fabric Transfer API: How to implement Storage< | + | ====== Fabric Transfer API: How to implement Storage< |
//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 5: | Line 5: | ||
It's possible to implement directly by implementing the interface and filling the methods, but Fabric API already provides many implementations that you can use and combine for almost any task. | It's possible to implement directly by implementing the interface and filling the methods, but Fabric API already provides many implementations that you can use and combine for almost any task. | ||
- | ==== Overview of the base implementations ==== | + | ===== Overview of the base implementations |
- | === SingleVariantStorage === | + | ==== SingleVariantStorage |
[[https:// | [[https:// | ||
Line 41: | Line 41: | ||
</ | </ | ||
- | === FilteringStorage === | + | ==== FilteringStorage |
[[https:// | [[https:// | ||
Line 58: | Line 58: | ||
Subclassing '' | Subclassing '' | ||
- | === CombinedStorage === | + | ==== CombinedStorage |
[[https:// | [[https:// | ||
Line 70: | Line 70: | ||
- | ==== A more involved example ==== | + | ===== A more involved example |
To better understand how these classes can be combined together, let's write a machine that converts water to lava. Here are our requirements: | To better understand how these classes can be combined together, let's write a machine that converts water to lava. Here are our requirements: | ||
* The machine will have two internal " | * The machine will have two internal " | ||
Line 81: | Line 81: | ||
Finally, we will use '' | Finally, we will use '' | ||
- | === Internal tanks === | + | ==== Internal tanks ==== |
First, let's add the internal tanks to the block entity: | First, let's add the internal tanks to the block entity: | ||
<code java> | <code java> | ||
Line 124: | Line 124: | ||
// ... [other code omitted] | // ... [other code omitted] | ||
+ | } | ||
</ | </ | ||
- | === Conversion logic === | + | ==== Conversion logic ==== |
The conversion logic is straightforward: | The conversion logic is straightforward: | ||
<code java> | <code java> | ||
Line 143: | Line 144: | ||
</ | </ | ||
- | === Exposing the tanks to external pipes === | + | ==== Exposing the tanks to external pipes ==== |
We can use the filtering and combined storages to ensure that pipes can only do what we want them to do: | We can use the filtering and combined storages to ensure that pipes can only do what we want them to do: | ||
<code java> | <code java> |
tutorial/transfer-api_fluid_implementation.1643833625.txt.gz · Last modified: 2022/02/02 20:27 by technici4n