Java Code Examples for appeng.api.storage.data.IAEItemStack#getItemStack()

The following examples show how to use appeng.api.storage.data.IAEItemStack#getItemStack() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 6 votes vote down vote up
@ScriptCallable(description = "Get a list of the stored and craftable items in the network.", returnTypes = ReturnType.TABLE)
public List<?> getAvailableItems(IGridHost host,
		@Env(Constants.ARG_CONVERTER) IConverter converter,
		@Optionals @Arg(name = "details", description = "Format of stored items details (defalt: none)") ItemDetails format) {
	IStorageGrid storageGrid = getStorageGrid(host);
	final IItemList<IAEItemStack> storageList = storageGrid.getItemInventory().getStorageList();

	List<Object> result = Lists.newArrayList();
	for (IAEItemStack stack : storageList) {
		@SuppressWarnings("unchecked")
		Map<String, Object> map = (Map<String, Object>)converter.fromJava(stack);
		if (format != null && format != ItemDetails.NONE) {
			final ItemStack itemStack = stack.getItemStack();
			if (format == ItemDetails.PROXY) map.put("item", OpcAccess.itemStackMetaBuilder.createProxy(itemStack));
			else if (format == ItemDetails.ALL) map.put("item", itemStack);
		}
		result.add(map);
	}

	return result;
}
 
Example 2
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(description = "Retrieves details about the specified item from the ME Network.", returnTypes = ReturnType.OBJECT)
public Object getItemDetail(IGridHost host,
		@Arg(name = "item", description = "Details of the item you are looking for") ItemFingerprint needle,
		@Optionals @Arg(name = "proxy", description = "If false, method will compute whole table, instead of returning proxy") Boolean proxy) {
	final IItemList<IAEItemStack> items = getStorageGrid(host).getItemInventory().getStorageList();
	final IAEItemStack stack = findStack(items, needle);
	if (stack == null) return null;
	ItemStack vanillaStack = stack.getItemStack();
	return proxy != Boolean.FALSE? OpcAccess.itemStackMetaBuilder.createProxy(vanillaStack) : vanillaStack;
}
 
Example 3
Source File: AE2DiskInventoryItemHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void getStacksInItem(ItemStack stack, List<ItemStack> curStacks){
    IMEInventoryHandler<IAEItemStack> cellInventoryHandler = cellRegistry.getCellInventory(stack, null, StorageChannel.ITEMS);
    if(cellInventoryHandler != null) {
        IItemList<IAEItemStack> cellItemList = storageHelper.createItemList();
        cellInventoryHandler.getAvailableItems(cellItemList);
        for(IAEItemStack aeStack : cellItemList) {
            ItemStack st = aeStack.getItemStack();
            st.stackSize = (int)aeStack.getStackSize();//Do another getStacksize, as above retrieval caps to 64.
            curStacks.add(st);
        }
    }
}