当前位置: 首页>>代码示例>>Java>>正文


Java IAEItemStack.getItemStack方法代码示例

本文整理汇总了Java中appeng.api.storage.data.IAEItemStack.getItemStack方法的典型用法代码示例。如果您正苦于以下问题:Java IAEItemStack.getItemStack方法的具体用法?Java IAEItemStack.getItemStack怎么用?Java IAEItemStack.getItemStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在appeng.api.storage.data.IAEItemStack的用法示例。


在下文中一共展示了IAEItemStack.getItemStack方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAvailableItems

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
@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;
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:22,代码来源:AdapterNetwork.java

示例2: extractStack

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
/**
 * Extracts items from the network.
 *
 * @param target
 * @return Extracted stack.
 */
public ItemStack extractStack( final ItemStack target )
{
	// Get the item monitor
	IMEMonitor<IAEItemStack> monitor = this.getItemInventory();
	if( monitor == null )
	{
		return null;
	}

	// Create the AE stack
	IAEItemStack aeRequest = AEApi.instance().storage().createItemStack( target );

	// Set size
	aeRequest.setStackSize( Math.min( target.stackSize, this.maxItemRate ) );

	// Extract
	IAEItemStack extracted = AEApi.instance().storage().poweredExtraction( this.getEnergyGrid(), monitor, aeRequest, this.actionSource );
	if( extracted == null )
	{
		return null;
	}

	return extracted.getItemStack();
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:31,代码来源:AIAENetworkGolem.java

示例3: getItemDetail

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
@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;
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:11,代码来源:AdapterNetwork.java

示例4: requestCraftingReplenishment

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
/**
 * Attempts to extract an item from the network.
 * Used when crafting to replenish the crafting grid.
 *
 * @param itemStack
 * @return
 */
public ItemStack requestCraftingReplenishment( final ItemStack itemStack )
{
	if( this.monitor == null )
	{
		return null;
	}

	// Search the players inventory
	ItemStack replenishmentPlayer = this.takeItemFromPlayer( itemStack, 1 );
	if( replenishmentPlayer != null )
	{
		return replenishmentPlayer;
	}

	// Create the AE request stack
	IAEItemStack requestStack = AEApi.instance().storage().createItemStack( itemStack );

	// Set the request amount to one
	requestStack.setStackSize( 1 );

	// Attempt an extraction
	IAEItemStack replenishmentAE = this.monitor.extractItems( requestStack, Actionable.MODULATE, this.playerSource );

	// Did we get a replenishment?
	if( replenishmentAE != null )
	{
		return replenishmentAE.getItemStack();
	}

	// Did not get a replenishment, search for items that match.

	// Get a list of all items in the ME network
	IItemList<IAEItemStack> networkItems = this.monitor.getStorageList();

	// Search all items
	for( IAEItemStack potentialMatch : networkItems )
	{
		// Does the request match?
		if( this.doStacksMatch( requestStack, potentialMatch ) )
		{
			// Found a match
			requestStack = potentialMatch.copy();

			// Set the request amount to one
			requestStack.setStackSize( 1 );

			// Attempt an extraction
			replenishmentAE = this.monitor.extractItems( requestStack, Actionable.MODULATE, this.playerSource );

			// Did we get a replenishment?
			if( ( replenishmentAE != null ) && ( replenishmentAE.getStackSize() > 0 ) )
			{
				return replenishmentAE.getItemStack();
			}
		}

	}

	// No matches at all :(
	return null;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:69,代码来源:ContainerPartArcaneCraftingTerminal.java


注:本文中的appeng.api.storage.data.IAEItemStack.getItemStack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。