本文整理汇总了Java中openperipheral.api.Constants.ARG_CONVERTER属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.ARG_CONVERTER属性的具体用法?Java Constants.ARG_CONVERTER怎么用?Java Constants.ARG_CONVERTER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类openperipheral.api.Constants
的用法示例。
在下文中一共展示了Constants.ARG_CONVERTER属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAvailableItems
@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;
}
示例2: requestCrafting
@ScriptCallable(description = "Requests the specified item to get crafted.")
public void requestCrafting(IActionHost host,
@Env(Constants.ARG_ACCESS) IArchitectureAccess access,
@Env(Constants.ARG_CONVERTER) IConverter converter,
@Arg(name = "fingerprint", description = "Details of the item you want to craft. Can be found with .getStackInSlot on inventory and .getAvailableItems on AE network") ItemFingerprint needle,
@Optionals @Arg(name = "qty", description = "The quantity of items you want to craft") Long quantity,
@Arg(name = "cpu", description = "The name of the CPU you want to use") String wantedCpuName) {
ICraftingGrid craftingGrid = getCraftingGrid(host);
if (quantity == null) quantity = 1L;
ICraftingCPU wantedCpu = findCpu(craftingGrid, wantedCpuName);
IStorageGrid storageGrid = getStorageGrid(host);
IMEMonitor<IAEItemStack> monitor = storageGrid.getItemInventory();
IAEItemStack stack = findCraftableStack(storageGrid.getItemInventory().getStorageList(), needle);
Preconditions.checkArgument(stack != null, "Can't find craftable item fingerprint %s", needle);
final IAEItemStack toCraft = stack.copy();
toCraft.setStackSize(quantity);
// Create a new CraftingCallback. This callback is called when
// the network finished calculating the required items. It can do two things for us:
// a) It sends an event when items are missing to complete the request
// b) Otherwise it starts the crafting job, which itself is a CraftingRequester OSsending more events to the computer.
final CraftingCallback craftingCallback = new CraftingCallback(access, converter, craftingGrid, monitor, host, wantedCpu, toCraft);
// We will need access to the worldObj of the ME Interface -> cast to TileEntity
final TileEntity tileEntity = (TileEntity)host;
// Tell the craftingGrid to begin calculating and to report everything to the CraftingCallback
craftingGrid.beginCraftingJob(tileEntity.getWorldObj(), getGrid(host), new MachineSource(host), toCraft, craftingCallback);
}