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


Java IActionHost类代码示例

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


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

示例1: requestCrafting

import appeng.api.networking.security.IActionHost; //导入依赖的package包/类
@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);

}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:35,代码来源:AdapterInterface.java

示例2: CraftingCallback

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

示例3: postChange

import appeng.api.networking.security.IActionHost; //导入依赖的package包/类
/**
 * A change occurred in the sub-grid, inform the host grid.
 */
@Override
public void postChange( final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final BaseActionSource actionSource )
{
	try
	{
		IActionHost actionHost = null;

		// Get the action source
		if( actionSource instanceof PlayerSource )
		{
			// From the player source
			actionHost = ( (PlayerSource)actionSource ).via;
		}
		else if( actionSource instanceof MachineSource )
		{
			// From the machine source
			actionHost = ( (MachineSource)actionSource ).via;
		}

		// Ensure there is an action host
		if( actionHost != null )
		{
			// Post update if change did not come from host grid, prevents double posting.
			if( actionHost.getActionableNode().getGrid() != this.partStorageBus.getActionableNode().getGrid() )
			{
				// Update the host grid
				this.postAlterationToHostGrid( change );
			}
		}
	}
	catch( Exception e )
	{

	}
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:39,代码来源:HandlerEssentiaStorageBusInterface.java

示例4: ContainerEssentiaCell

import appeng.api.networking.security.IActionHost; //导入依赖的package包/类
/**
 * Creates the container.
 *
 * @param player
 * The player that owns this container.
 * @param world
 * The world the ME chest is in.
 * @param x
 * X position of the ME chest.
 * @param y
 * Y position of the ME chest.
 * @param z
 * Z position of the ME chest.
 */
public ContainerEssentiaCell( final EntityPlayer player, final World world, final int x, final int y, final int z )
{
	// Call the super-constructor
	super( player );

	// Get the tile entity for the chest
	this.hostChest = (TileChest)world.getTileEntity( x, y, z );

	// Is this server side?
	if( EffectiveSide.isServerSide() )
	{
		/*
		 * Note: Casting the hostChest to an object is required to prevent the compiler
		 * from seeing the soft-dependencies of AE2, such a buildcraft, which it attempts
		 * to resolve at compile time.
		 * */
		Object hostObject = this.hostChest;
		this.chestSaveProvider = ( (ISaveProvider)hostObject );

		// Create the action source
		this.playerSource = new PlayerSource( this.player, (IActionHost)hostObject );
	}
	else
	{
		// Request a full update from the server
		Packet_S_EssentiaCellTerminal.sendFullUpdateRequest( player );
	}

	// Bind our inventory
	this.bindToInventory( this.privateInventory );

}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:47,代码来源:ContainerEssentiaCell.java

示例5: exportItem

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

示例6: CraftingRequester

import appeng.api.networking.security.IActionHost; //导入依赖的package包/类
public CraftingRequester(IActionHost original, IArchitectureAccess access, Object requestedStack) {
	this.original = original;
	this.access = access;
	this.requestedStack = requestedStack;
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:6,代码来源:CraftingRequester.java


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