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


Java ICraftingJob类代码示例

本文整理汇总了Java中appeng.api.networking.crafting.ICraftingJob的典型用法代码示例。如果您正苦于以下问题:Java ICraftingJob类的具体用法?Java ICraftingJob怎么用?Java ICraftingJob使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: calculationComplete

import appeng.api.networking.crafting.ICraftingJob; //导入依赖的package包/类
@Override
public void calculationComplete(ICraftingJob job) {
	// IsSimulation is true when the job cannot be processed because items
	// are missing, i.e.
	// not available in the system or not recursively craftable.
	// In that case we will send an event to the computer with the missing
	// ingredients.
	if (job.isSimulation()) {
		sendSimulationInfo(job);
	} else {
		// All items are available, we can start crafting now
		CraftingRequester craftingRequester = new CraftingRequester(actionHost, access, requestedStack);
		craftingGrid.submitJob(job, craftingRequester, wantedCpu, false, source);
	}
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:16,代码来源:CraftingCallback.java

示例2: sendSimulationInfo

import appeng.api.networking.crafting.ICraftingJob; //导入依赖的package包/类
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));
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:46,代码来源:CraftingCallback.java

示例3: execute

import appeng.api.networking.crafting.ICraftingJob; //导入依赖的package包/类
@Override
public void execute()
{
	// Sanity check.
	if( this.mode != Packet_S_ConfirmCraftingJob.MODE_REQUEST_CONFIRM )
	{
		return;
	}

	// NOTE: The code from here down was copied from "PacketCraftRequest" from AE2
	// The only change is which GUI is launched.

	if( this.player.openContainer instanceof ContainerCraftAmount )
	{
		final ContainerCraftAmount cca = (ContainerCraftAmount)this.player.openContainer;
		final Object target = cca.getTarget();
		if( target instanceof IGridHost )
		{
			final IGridHost gh = (IGridHost)target;
			final IGridNode gn = gh.getGridNode( ForgeDirection.UNKNOWN );
			if( gn == null )
			{
				return;
			}

			final IGrid g = gn.getGrid();
			if( ( g == null ) || ( cca.getItemToCraft() == null ) )
			{
				return;
			}

			cca.getItemToCraft().setStackSize( this.amount );

			Future<ICraftingJob> futureJob = null;
			try
			{
				final ICraftingGrid cg = g.getCache( ICraftingGrid.class );
				futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null );

				final ContainerOpenContext context = cca.getOpenContext();
				if( context != null )
				{
					// Begin Thaumic Energistics Changes ===============================

					ThEGuiHandler.launchGui( ThEGuiHandler.AUTO_CRAFTING_CONFIRM, this.player, this.player.worldObj, 0, 0, 0 );

					// End Thaumic Energistics Changes ===============================

					if( this.player.openContainer instanceof ContainerCraftConfirm )
					{
						final ContainerCraftConfirm ccc = (ContainerCraftConfirm)this.player.openContainer;
						ccc.setAutoStart( this.heldShift );
						ccc.setJob( futureJob );
						cca.detectAndSendChanges();
					}
				}
			}
			catch( final Throwable e )
			{
				if( futureJob != null )
				{
					futureJob.cancel( true );
				}
				AELog.error( e );
			}
		}
	}
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:69,代码来源:Packet_S_ConfirmCraftingJob.java


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