appeng.api.config.Actionable Java Examples

The following examples show how to use appeng.api.config.Actionable. 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: MEMonitorHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public StackType extractItems( StackType request, Actionable mode, BaseActionSource src )
{
	if( mode == Actionable.SIMULATE )
	{
		return this.getHandler().extractItems( request, mode, src );
	}
	return this.monitorDifference( request.copy(), this.getHandler().extractItems( request, mode, src ), true, src );
}
 
Example #2
Source File: MEMonitorHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public StackType injectItems( StackType input, Actionable mode, BaseActionSource src )
{
	if( mode == Actionable.SIMULATE )
	{
		return this.getHandler().injectItems( input, mode, src );
	}
	return this.monitorDifference( input.copy(), this.getHandler().injectItems( input, mode, src ), false, src );
}
 
Example #3
Source File: MEMonitorHandler.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public StackType extractItems(StackType request, Actionable mode, BaseActionSource src)
{
	if ( mode == Actionable.SIMULATE )
		return getHandler().extractItems( request, mode, src );
	return monitorDifference(request.copy(), getHandler().extractItems(request, mode, src), true, src);
}
 
Example #4
Source File: MEMonitorHandler.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public StackType injectItems(StackType input, Actionable mode, BaseActionSource src)
{
	if ( mode == Actionable.SIMULATE )
		return getHandler().injectItems( input, mode, src );
	return monitorDifference(input.copy(), getHandler().injectItems(input, mode, src), false, src);
}
 
Example #5
Source File: SemiBlockRequesterAE.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.AE2)
public IAEItemStack injectItems(IAEItemStack arg0, Actionable arg1, BaseActionSource arg2){
    return arg0;
}
 
Example #6
Source File: AdapterInterface.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@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 #7
Source File: SemiBlockRequesterAE.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.AE2)
public IAEItemStack extractItems(IAEItemStack arg0, Actionable arg1, BaseActionSource arg2){
    return null;
}
 
Example #8
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 #9
Source File: CraftingRequester.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@Override
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
	return items;
}
 
Example #10
Source File: MotorModifierAE2.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
public double injectAEPower(double amt, Actionable mode) {

    return amt - injectPower(amt, mode == Actionable.MODULATE);
}
 
Example #11
Source File: MotorModifierAE2.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {

    return 0;
}
 
Example #12
Source File: IAEPowerStorage.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Inject amt, power into the device, it will store what it can, and return the amount unable to be stored.
 *
 * @param amt  to be injected amount
 * @param mode action mode
 *
 * @return amount of power which was unable to be stored
 */
double injectAEPower( double amt, Actionable mode );
 
Example #13
Source File: IMEInventory.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Extract the specified item from the ME Inventory
 *
 * @param request item to request ( with stack size. )
 * @param mode    simulate, or perform action?
 *
 * @return returns the number of items extracted, null
 */
StackType extractItems( StackType request, Actionable mode, BaseActionSource src );
 
Example #14
Source File: IMEInventory.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Store new items, or simulate the addition of new items into the ME Inventory.
 *
 * @param input item to add.
 * @param type  action type
 * @param src   action source
 *
 * @return returns the number of items not added.
 */
StackType injectItems( StackType input, Actionable type, BaseActionSource src );
 
Example #15
Source File: IEnergyGrid.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * AE will accept any power, and store it, to maintain sanity please don't send more then 10,000 at a time.
 *
 * IMPORTANT: Network power knows no bounds, for less spamy power flow, networks can store more then their allotted
 * storage, however, it should be kept to a minimum, to help with this, this method returns the networks current
 * OVERFLOW, this is not energy you can store some where else, its already stored in the network, you can extract it
 * if you want, however it it owned by the network, this is different then IAEEnergyStore
 *
 * Another important note, is that if a network that had overflow is deleted, its power is gone, this is one of the
 * reasons why keeping overflow to a minimum is important.
 *
 * @param amt  power to inject into the network
 * @param mode should the action be simulated or performed?
 *
 * @return the amount of power that the network has OVER the limit.
 */
double injectPower( double amt, Actionable mode );
 
Example #16
Source File: IEnergyGridProvider.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * internal use only
 */
double injectAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen );
 
Example #17
Source File: IEnergyGridProvider.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * internal use only
 */
double extractAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen );
 
Example #18
Source File: IAEPowerStorage.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Inject amt, power into the device, it will store what it can, and return the amount unable to be stored.
 * 
 * @param amt to be injected amount
 * @param mode action mode
 * 
 * @return amount of power which was unable to be stored
 */
public double injectAEPower(double amt, Actionable mode);
 
Example #19
Source File: IEnergySource.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Extract power from the network.
 *
 * @param amt  extracted power
 * @param mode should the action be simulated or performed?
 *
 * @return returns extracted power.
 */
double extractAEPower( double amt, Actionable mode, PowerMultiplier usePowerMultiplier );
 
Example #20
Source File: ICraftingRequester.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * items are injected into the requester as they are completed, any items that cannot be taken, or are unwanted can
 * be returned.
 *
 * @param items item
 * @param mode  action mode
 *
 * @return unwanted item
 */
IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode );
 
Example #21
Source File: ICraftingRequester.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * items are injected into the requester as they are completed, any items that cannot be taken, or are unwanted can
 * be returned.
 * 
 * @param items item
 * @param mode action mode
 * @return unwanted item
 */
IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode);
 
Example #22
Source File: IEnergySource.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Extract power from the network.
 * 
 * @param amt extracted power
 * @param mode should the action be simulated or performed?
 * @return returns extracted power.
 */
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier);
 
Example #23
Source File: IMEInventory.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Extract the specified item from the ME Inventory
 * 
 * @param request
 *            item to request ( with stack size. )
 * @param mode
 *            simulate, or perform action?
 * @return returns the number of items extracted, null
 */
public StackType extractItems(StackType request, Actionable mode, BaseActionSource src);
 
Example #24
Source File: IMEInventory.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Store new items, or simulate the addition of new items into the ME Inventory.
 * 
 * @param input item to add.
 * @param type action type
 * @param src action source
 * @return returns the number of items not added.
 */
public StackType injectItems(StackType input, Actionable type, BaseActionSource src);
 
Example #25
Source File: IEnergyGrid.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * AE will accept any power, and store it, to maintain sanity please don't send more then 10,000 at a time.
 * 
 * IMPORTANT: Network power knows no bounds, for less spamy power flow, networks can store more then their allotted
 * storage, however, it should be kept to a minimum, to help with this, this method returns the networks current
 * OVERFLOW, this is not energy you can store some where else, its already stored in the network, you can extract it
 * if you want, however it it owned by the network, this is different then IAEEnergyStore
 * 
 * Another important note, is that if a network that had overflow is deleted, its power is gone, this is one of the
 * reasons why keeping overflow to a minimum is important.
 * 
 * @param amt
 *            power to inject into the network
 * @param mode
 *            should the action be simulated or performed?
 * @return the amount of power that the network has OVER the limit.
 */
public double injectPower(double amt, Actionable mode);
 
Example #26
Source File: IEnergyGridProvider.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * internal use only
 */
public double injectAEPower(double amt, Actionable mode, Set<IEnergyGrid> seen);
 
Example #27
Source File: IEnergyGridProvider.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
/**
 * internal use only
 */
public double extractAEPower(double amt, Actionable mode, Set<IEnergyGrid> seen);