Merge pull request #2 from repo-alt/AE2-integration-2928

https://github.com/MightyPirates/OpenComputers/issues/2928
This commit is contained in:
bartimaeusnek 2019-04-24 01:11:44 +02:00 committed by GitHub
commit 93427705f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,10 @@ package li.cil.oc.integration.appeng;
import appeng.api.AEApi;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.implementations.items.IStorageCell;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import net.minecraft.item.ItemStack;
import li.cil.oc.api.driver.Converter;
import java.util.Map;
@ -31,6 +35,11 @@ public final class ConverterCellInventory implements Converter {
output.put("name", cell.getItemStack().getDisplayName());
} else if (value instanceof ICellInventoryHandler) {
convert(((ICellInventoryHandler) value).getCellInv(), output);
} else if ((value instanceof ItemStack) && (((ItemStack)value).getItem() instanceof IStorageCell)) {
IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell().getCellInventory((ItemStack) value, null, StorageChannel.ITEMS);
if (inventory instanceof ICellInventoryHandler)
convert(((ICellInventoryHandler) inventory).getCellInv(), output);
}
}
}