appeng.api.storage.data.IItemList Java Examples

The following examples show how to use appeng.api.storage.data.IItemList. 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: SemiBlockRequester.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.AE2)
public void onStackChange(IItemList arg0, IAEStack arg1, IAEStack arg2, BaseActionSource arg3, StorageChannel arg4){
    if(craftingGrid != null) {
        ICraftingGrid grid = (ICraftingGrid)craftingGrid;
        for(int i = 0; i < getFilters().getSizeInventory(); i++) {
            ItemStack s = getFilters().getStackInSlot(i);
            if(s != null) {
                if(!grid.isRequesting(AEApi.instance().storage().createItemStack(s))) {
                    getFilters().setInventorySlotContents(i, null);
                    notifyNetworkOfCraftingChange();
                }
            }
        }
    }
}
 
Example #2
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 #3
Source File: SemiBlockRequesterAE.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.AE2)
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> arg0){
    for(IAEItemStack stack : getProvidingItems()) {
        stack.setCountRequestable(stack.getStackSize());
        arg0.addRequestable(stack);
    }
    return arg0;
}
 
Example #4
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 #5
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);
        }
    }
}
 
Example #6
Source File: MEMonitorHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IItemList<StackType> getStorageList()
{
	if( this.hasChanged )
	{
		this.hasChanged = false;
		this.cachedList.resetStatus();
		return this.getAvailableItems( this.cachedList );
	}

	return this.cachedList;
}
 
Example #7
Source File: MEMonitorHandler.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IItemList<StackType> getStorageList()
{
	if ( hasChanged )
	{
		hasChanged = false;
		cachedList.resetStatus();
		return getAvailableItems( cachedList );
	}

	return cachedList;
}
 
Example #8
Source File: AdapterGridBase.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
protected static IAEItemStack findCraftableStack(IItemList<IAEItemStack> items, ItemFingerprint fingerprint) {
	for (IAEItemStack stack : items)
		if (compareToAEStack(fingerprint, stack, true)) return stack;

	return null;
}
 
Example #9
Source File: IMEMonitor.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This method is discouraged when accessing data via a IMEMonitor
 */
@Override
@Deprecated
IItemList<T> getAvailableItems( IItemList out );
 
Example #10
Source File: MEMonitorHandler.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public IItemList<StackType> getAvailableItems( IItemList out )
{
	return this.getHandler().getAvailableItems( out );
}
 
Example #11
Source File: MEMonitorHandler.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public MEMonitorHandler( IMEInventoryHandler<StackType> t, StorageChannel chan )
{
	this.internalHandler = t;
	this.cachedList = (IItemList<StackType>) chan.createList();
}
 
Example #12
Source File: MEMonitorHandler.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public MEMonitorHandler( IMEInventoryHandler<StackType> t )
{
	this.internalHandler = t;
	this.cachedList = (IItemList<StackType>) t.getChannel().createList();
}
 
Example #13
Source File: MEMonitorHandler.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
public MEMonitorHandler(IMEInventoryHandler<StackType> t) {
	internalHandler = t;
	cachedList = (IItemList<StackType>) t.getChannel().createList();
}
 
Example #14
Source File: AdapterGridBase.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
protected static IAEItemStack findStack(IItemList<IAEItemStack> items, ItemFingerprint fingerprint) {
	for (IAEItemStack stack : items)
		if (compareToAEStack(fingerprint, stack)) return stack;

	return null;
}
 
Example #15
Source File: CraftingCallback.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
private void sendSimulationInfo(ICraftingJob job) {
	// Grab the list of items from the job (this is basically the same
	// list the ME Terminal shows when crafting an item).
	IItemList<IAEItemStack> plan = AEApi.instance().storage().createItemList();
	job.populatePlan(plan);

	// This procedure to determine whether an item is missing is
	// basically the same as
	// the one used by AE2. Taken from here:
	// https://github.com/AppliedEnergistics/Applied-Energistics-2/blob/rv2/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java
	List<IAEItemStack> missingItems = Lists.newArrayList();
	for (IAEItemStack needed : plan) {
		IAEItemStack toExtract = needed.copy();

		// Not sure why this is needed, but AE2 does it itself.
		toExtract.reset();
		toExtract.setStackSize(needed.getStackSize());

		// Simulate the extraction, this is basically a "fast" way to
		// check whether an item exists in the first place.
		// The idea is: if we can extract it, we can use it for crafting.
		IAEItemStack extracted = monitor.extractItems(toExtract, Actionable.SIMULATE, source);

		// If we could not extract the item, we are missing all of the
		// quantity that's required.
		// Otherwise we are only missing the difference between the two.
		// This can be 0 if we were able to extract all of the required items.
		long missing = needed.getStackSize();
		if (extracted != null) missing -= extracted.getStackSize();

		if (missing > 0) {
			IAEItemStack missingStack = needed.copy();
			missingItems.add(missingStack);
		}
	}

	// At this point missingItems should always have at least one
	// element, because isSimulation would return false.
	// But even if it's empty, we need to send event to unblock process

	access.signal(ModuleAppEng.CC_EVENT_STATE_CHANGED,
			converter.fromJava(this.requestedStack),
			"missing_items",
			converter.fromJava(missingItems));
}
 
Example #16
Source File: IMEMonitor.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Deprecated
/**
 * This method is discouraged when accessing data via a IMEMonitor
 */
public IItemList<T> getAvailableItems(IItemList out);
 
Example #17
Source File: MEMonitorHandler.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
public MEMonitorHandler(IMEInventoryHandler<StackType> t, StorageChannel chan) {
	internalHandler = t;
	cachedList = (IItemList<StackType>) chan.createList();
}
 
Example #18
Source File: MEMonitorHandler.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
public IItemList<StackType> getAvailableItems(IItemList out)
{
	return getHandler().getAvailableItems( out );
}
 
Example #19
Source File: IMEInventory.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * request a full report of all available items, storage.
 *
 * @param out the IItemList the results will be written too
 *
 * @return returns same list that was passed in, is passed out
 */
IItemList<StackType> getAvailableItems( IItemList<StackType> out );
 
Example #20
Source File: IStackWatcherHost.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Called when a watched item changes amounts.
 *
 * @param o         changed item list
 * @param fullStack old stack
 * @param diffStack new stack
 * @param src       action source
 * @param chan      storage channel
 */
void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan );
 
Example #21
Source File: ICraftingJob.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Populates the plan list with stack size, and requestable values that represent the stored, and crafting job
 * contents respectively.
 *
 * @param plan plan
 */
void populatePlan( IItemList<IAEItemStack> plan );
 
Example #22
Source File: IStorageHelper.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @return a new instance of {@link IItemList} for fluids
 */
IItemList<IAEFluidStack> createFluidList();
 
Example #23
Source File: IMEInventory.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * request a full report of all available items, storage.
 * 
 * @param out
 *            the IItemList the results will be written too
 * @return returns same list that was passed in, is passed out
 */
public IItemList<StackType> getAvailableItems(IItemList<StackType> out);
 
Example #24
Source File: IStackWatcherHost.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Called when a watched item changes amounts.
 * 
 * @param o changed item list
 * @param fullStack old stack
 * @param diffStack new stack
 * @param src action source
 * @param chan storage channel
 */
void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan);
 
Example #25
Source File: IMEMonitor.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get access to the full item list of the network, preferred over {@link IMEInventory} .getAvailableItems(...)
 *
 * @return full storage list.
 */
IItemList<T> getStorageList();
 
Example #26
Source File: IStorageHelper.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @return a new INSTANCE of {@link IItemList} for items
 */
IItemList<IAEItemStack> createItemList();
 
Example #27
Source File: IStorageHelper.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @return a new INSTANCE of {@link IItemList} for fluids
 */
IItemList<IAEFluidStack> createFluidList();
 
Example #28
Source File: ICraftingJob.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Populates the plan list with stack size, and requestable values that represent the stored, and crafting job
 * contents respectively.
 * 
 * @param plan plan
 */
void populatePlan(IItemList<IAEItemStack> plan);
 
Example #29
Source File: IStorageHelper.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @return a new instance of {@link IItemList} for items
 */
IItemList<IAEItemStack> createItemList();
 
Example #30
Source File: IMEMonitor.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get access to the full item list of the network, preferred over {@link IMEInventory} .getAvailableItems(...)
 * 
 * @return full storage list.
 */
IItemList<T> getStorageList();