appeng.api.storage.data.IAEItemStack Java Examples
The following examples show how to use
appeng.api.storage.data.IAEItemStack.
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 |
@Override @Optional.Method(modid = ModIds.AE2) public void onRequestChange(ICraftingGrid grid, IAEItemStack aeStack){ craftingGrid = grid; ItemStack stack = aeStack.getItemStack().copy(); int freeSlot = -1; for(int i = 0; i < getFilters().getSizeInventory(); i++) { ItemStack s = getFilters().getStackInSlot(i); if(s != null) { if(stack.isItemEqual(s)) { s.stackSize = stack.stackSize; if(s.stackSize == 0) getFilters().setInventorySlotContents(i, null); return; } } else if(freeSlot == -1) { freeSlot = i; } } if(freeSlot >= 0) { getFilters().setInventorySlotContents(freeSlot, stack.copy()); } }
Example #2
Source File: AdapterNetwork.java From OpenPeripheral-Integration with MIT License | 6 votes |
@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: SemiBlockRequester.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Optional.Method(modid = ModIds.AE2) public List<IAEItemStack> getProvidingItems(){ List<IAEItemStack> stacks = new ArrayList<IAEItemStack>(); for(TileEntity te : providingInventories.keySet()) { IInventory inv = IOHelper.getInventoryForTE(te); if(inv != null) { for(int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); if(stack != null) stacks.add(AEApi.instance().storage().createItemStack(stack)); } } } return stacks; }
Example #4
Source File: SemiBlockRequester.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Optional.Method(modid = ModIds.AE2) private void updateProvidingItems(ICraftingProviderHelper cHelper){ IStackWatcher sWatcher = (IStackWatcher)stackWatcher; ICraftingWatcher cWatcher = (ICraftingWatcher)craftingWatcher; if(sWatcher != null) sWatcher.clear(); if(cWatcher != null) cWatcher.clear(); for(IAEItemStack stack : getProvidingItems()) { if(sWatcher != null) sWatcher.add(stack); if(cWatcher != null) cWatcher.add(stack); if(cHelper != null) cHelper.setEmitable(stack); } }
Example #5
Source File: AdapterInterface.java From OpenPeripheral-Integration with MIT License | 5 votes |
@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); }
Example #6
Source File: CraftingCallback.java From OpenPeripheral-Integration with MIT License | 5 votes |
public CraftingCallback(IArchitectureAccess access, IConverter converter, ICraftingGrid craftingGrid, IMEMonitor<IAEItemStack> monitor, IActionHost actionHost, ICraftingCPU wantedCpu, IAEItemStack requestedStack) { this.access = access; this.converter = converter; this.monitor = monitor; this.source = new MachineSource(actionHost); this.actionHost = actionHost; this.craftingGrid = craftingGrid; this.wantedCpu = wantedCpu; this.requestedStack = converter.fromJava(requestedStack); }
Example #7
Source File: ConverterAEItemStack.java From OpenPeripheral-Integration with MIT License | 5 votes |
@Override public Object convert(IConverter registry, IAEItemStack aeStack) { ItemFingerprint fingerprint = new ItemFingerprint(aeStack.getItem(), aeStack.getItemDamage(), getTag(aeStack)); Map<String, Object> result = Maps.newHashMap(); result.put("fingerprint", fingerprint); result.put("size", aeStack.getStackSize()); result.put("is_craftable", aeStack.isCraftable()); result.put("is_fluid", aeStack.isFluid()); result.put("is_item", aeStack.isItem()); return registry.fromJava(result); }
Example #8
Source File: AdapterNetwork.java From OpenPeripheral-Integration with MIT License | 5 votes |
@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 #9
Source File: SemiBlockRequesterAE.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@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 #10
Source File: AE2DiskInventoryItemHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@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 #11
Source File: AdapterGridBase.java From OpenPeripheral-Integration with MIT License | 4 votes |
protected static IAEItemStack findStack(IItemList<IAEItemStack> items, ItemFingerprint fingerprint) { for (IAEItemStack stack : items) if (compareToAEStack(fingerprint, stack)) return stack; return null; }
Example #12
Source File: SemiBlockRequesterAE.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override @Optional.Method(modid = ModIds.AE2) public boolean isPrioritized(IAEItemStack arg0){ return false; }
Example #13
Source File: SemiBlockRequesterAE.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override @Optional.Method(modid = ModIds.AE2) public boolean canAccept(IAEItemStack arg0){ return false; }
Example #14
Source File: SemiBlockRequesterAE.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override @Optional.Method(modid = ModIds.AE2) public IAEItemStack injectItems(IAEItemStack arg0, Actionable arg1, BaseActionSource arg2){ return arg0; }
Example #15
Source File: SemiBlockRequesterAE.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override @Optional.Method(modid = ModIds.AE2) public IAEItemStack extractItems(IAEItemStack arg0, Actionable arg1, BaseActionSource arg2){ return null; }
Example #16
Source File: AdapterGridBase.java From OpenPeripheral-Integration with MIT License | 4 votes |
protected static boolean compareToAEStack(ItemFingerprint needle, IAEItemStack hayStack, boolean craftable) { return (hayStack.isCraftable() == craftable) && compareToAEStack(needle, hayStack); }
Example #17
Source File: AdapterGridBase.java From OpenPeripheral-Integration with MIT License | 4 votes |
protected static IAEItemStack findCraftableStack(IItemList<IAEItemStack> items, ItemFingerprint fingerprint) { for (IAEItemStack stack : items) if (compareToAEStack(fingerprint, stack, true)) return stack; return null; }
Example #18
Source File: AdapterInterface.java From OpenPeripheral-Integration with MIT License | 4 votes |
@ScriptCallable(description = "Exports the specified item into the target inventory.", returnTypes = ReturnType.TABLE) public IAEItemStack exportItem(Object tileEntityInterface, @Arg(name = "fingerprint", description = "Details of the item you want to export (can be result of .getStackInSlot() or .getAvailableItems())") ItemFingerprint needle, @Arg(name = "direction", description = "Location of target inventory") ForgeDirection direction, @Optionals @Arg(name = "maxAmount", description = "The maximum amount of items you want to export") Integer maxAmount, @Arg(name = "intoSlot", description = "The slot in the other inventory that you want to export into") Index intoSlot) { final IActionHost host = (IActionHost)tileEntityInterface; final IInventory neighbor = getNeighborInventory(tileEntityInterface, direction); Preconditions.checkArgument(neighbor != null, "No neighbour attached"); if (intoSlot == null) intoSlot = Index.fromJava(-1, 0); IStorageGrid storageGrid = getStorageGrid(host); IMEMonitor<IAEItemStack> monitor = storageGrid.getItemInventory(); IAEItemStack stack = findStack(monitor.getStorageList(), needle); Preconditions.checkArgument(stack != null, "Can't find item fingerprint %s", needle); IAEItemStack toExtract = stack.copy(); if (maxAmount == null || maxAmount < 1 || maxAmount > toExtract.getItemStack().getMaxStackSize()) { toExtract.setStackSize(toExtract.getItemStack().getMaxStackSize()); } else { toExtract.setStackSize(maxAmount); } // Actually export the items from the ME system. MachineSource machineSource = new MachineSource(host); IAEItemStack extracted = monitor.extractItems(toExtract, Actionable.MODULATE, machineSource); if (extracted == null) return null; ItemStack toInsert = extracted.getItemStack().copy(); // Put the item in the neighbor inventory if (ItemDistribution.insertItemIntoInventory(neighbor, toInsert, direction.getOpposite(), intoSlot.value)) { neighbor.markDirty(); } // If we've moved some items, but others are still remaining. // Insert them back into the ME system. if (toInsert.stackSize > 0) { final IAEItemStack toReturn = AEApi.instance().storage().createItemStack(toInsert); monitor.injectItems(toReturn, Actionable.MODULATE, machineSource); extracted.decStackSize(toInsert.stackSize); } // Return what we've actually extracted return extracted; }
Example #19
Source File: CraftingCallback.java From OpenPeripheral-Integration with MIT License | 4 votes |
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 #20
Source File: ConverterAEItemStack.java From OpenPeripheral-Integration with MIT License | 4 votes |
public static NBTTagCompound getTag(IAEItemStack stack) { final IAETagCompound tag = stack.getTagCompound(); return tag != null? tag.getNBTTagCompoundCopy() : null; }
Example #21
Source File: CraftingRequester.java From OpenPeripheral-Integration with MIT License | 4 votes |
@Override public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) { return items; }
Example #22
Source File: ICraftingGrid.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * @param what to be requested item * * @return true if the item can be requested via a crafting emitter. */ boolean canEmitFor( IAEItemStack what );
Example #23
Source File: ICraftingGrid.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * Begin calculating a crafting job. * * @param world crafting world * @param grid network * @param actionSrc source * @param craftWhat result * @param callback callback * -- optional * * @return a future which will at an undetermined point in the future get you the {@link ICraftingJob} do not wait * on this, your be waiting forever. */ Future<ICraftingJob> beginCraftingJob( World world, IGrid grid, BaseActionSource actionSrc, IAEItemStack craftWhat, ICraftingCallback callback );
Example #24
Source File: ICraftingGrid.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * is this item being crafted? * * @param aeStackInSlot item being crafted * * @return true if it is being crafting */ boolean isRequesting( IAEItemStack aeStackInSlot );
Example #25
Source File: ICraftingPatternDetails.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * @return a list of the inputs, will include nulls. */ IAEItemStack[] getInputs();
Example #26
Source File: ICraftingPatternDetails.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * @return a list of the inputs, will be clean */ IAEItemStack[] getCondensedInputs();
Example #27
Source File: ICraftingPatternDetails.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * @return a list of the outputs, will be clean */ IAEItemStack[] getCondensedOutputs();
Example #28
Source File: ICraftingPatternDetails.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * @return a list of the outputs, will include nulls. */ IAEItemStack[] getOutputs();
Example #29
Source File: IStorageCell.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * Allows you to fine tune which items are allowed on a given cell, if you * don't care, just return false; As the handler for this type of cell is * still the default cells, the normal AE black list is also applied. * * @param cellItem item * @param requestedAddition requested addition * * @return true to preventAdditionOfItem */ boolean isBlackListed( ItemStack cellItem, IAEItemStack requestedAddition );
Example #30
Source File: IStorageMonitorable.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * Access the item inventory for the monitorable storage. */ IMEMonitor<IAEItemStack> getItemInventory();