forked from MightyPirates/OpenComputers
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Integration for AE2FC Fluid Storage Cells (#143)
Co-authored-by: Julia Dijkstra <[email protected]>
- Loading branch information
1 parent
0e5e32f
commit eede104
Showing
4 changed files
with
60 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/scala/li/cil/oc/integration/ae2fc/ConverterFluidCellInventory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package li.cil.oc.integration.ae2fc; | ||
|
||
import appeng.api.AEApi; | ||
import appeng.api.storage.IMEInventoryHandler; | ||
import appeng.api.storage.StorageChannel; | ||
import appeng.util.IterationCounter; | ||
import com.glodblock.github.common.storage.IFluidCellInventory; | ||
import com.glodblock.github.common.storage.IFluidCellInventoryHandler; | ||
import com.glodblock.github.common.storage.IStorageFluidCell; | ||
import li.cil.oc.api.driver.Converter; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import java.util.Map; | ||
|
||
public final class ConverterFluidCellInventory implements Converter { | ||
@Override | ||
public void convert(final Object value, final Map<Object, Object> output) { | ||
if (value instanceof IFluidCellInventory) { | ||
final IFluidCellInventory cell = (IFluidCellInventory) value; | ||
output.put("storedFluidTypes", cell.getStoredFluidTypes()); | ||
output.put("storedFluidCount", cell.getStoredFluidCount()); | ||
output.put("remainingFluidCount", cell.getRemainingFluidCount()); | ||
output.put("remainingFluidTypes", cell.getRemainingFluidTypes()); | ||
|
||
output.put("totalFluidTypes", cell.getTotalFluidTypes()); | ||
output.put( | ||
"availableFluids", | ||
cell.getAvailableItems(AEApi.instance().storage().createFluidList(), IterationCounter.fetchNewId())); | ||
|
||
output.put("totalBytes", cell.getTotalBytes()); | ||
output.put("freeBytes", cell.getFreeBytes()); | ||
output.put("usedBytes", cell.getUsedBytes()); | ||
output.put("unusedFluidCount", cell.getUnusedFluidCount()); | ||
output.put("canHoldNewFluid", cell.canHoldNewFluid()); | ||
|
||
output.put("name", cell.getItemStack().getDisplayName()); | ||
} else if (value instanceof IFluidCellInventoryHandler) { | ||
convert(((IFluidCellInventoryHandler) value).getCellInv(), output); | ||
} else if ((value instanceof ItemStack) && (((ItemStack) value).getItem() instanceof IStorageFluidCell)) { | ||
IMEInventoryHandler<?> inventory = AEApi.instance() | ||
.registries() | ||
.cell() | ||
.getCellInventory((ItemStack) value, null, StorageChannel.FLUIDS); | ||
if (inventory instanceof IFluidCellInventoryHandler) | ||
convert(((IFluidCellInventoryHandler) inventory).getCellInv(), output); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters