• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IMEMonitor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getFluidInventory

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory()
{
	// Check connectivity
	if( ( this.accessPoint == null ) || !this.isConnected() )
	{
		return null;
	}

	try
	{
		// Get the storage grid
		IStorageGrid storageGrid = this.accessPoint.getActionableNode().getGrid().getCache( IStorageGrid.class );

		// Return the monitor
		return storageGrid.getFluidInventory();
	}
	catch( Exception e )
	{
		// Ignored
	}

	return null;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:25,代码来源:WirelessAELink.java


示例2: getItemInventory

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
@Override
public IMEMonitor<IAEItemStack> getItemInventory()
{
	// Check connectivity
	if( ( this.accessPoint == null ) || !this.isConnected() )
	{
		return null;
	}

	try
	{
		// Get the storage grid
		IStorageGrid storageGrid = this.accessPoint.getActionableNode().getGrid().getCache( IStorageGrid.class );

		// Return the monitor
		return storageGrid.getItemInventory();
	}
	catch( Exception e )
	{
		// Ignored
	}

	return null;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:25,代码来源:WirelessAELink.java


示例3: extractStack

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
/**
 * Extracts items from the network.
 *
 * @param target
 * @return Extracted stack.
 */
public ItemStack extractStack( final ItemStack target )
{
	// Get the item monitor
	IMEMonitor<IAEItemStack> monitor = this.getItemInventory();
	if( monitor == null )
	{
		return null;
	}

	// Create the AE stack
	IAEItemStack aeRequest = AEApi.instance().storage().createItemStack( target );

	// Set size
	aeRequest.setStackSize( Math.min( target.stackSize, this.maxItemRate ) );

	// Extract
	IAEItemStack extracted = AEApi.instance().storage().poweredExtraction( this.getEnergyGrid(), monitor, aeRequest, this.actionSource );
	if( extracted == null )
	{
		return null;
	}

	return extracted.getItemStack();
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:31,代码来源:AIAENetworkGolem.java


示例4: requestCrafting

import appeng.api.storage.IMEMonitor; //导入依赖的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


示例5: CraftingCallback

import appeng.api.storage.IMEMonitor; //导入依赖的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


示例6: findAEStackFromItemStack

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
private IAEItemStack findAEStackFromItemStack(IMEMonitor<IAEItemStack> monitor, ItemStack item) {
	IAEItemStack stack = null;
	for (IAEItemStack temp : monitor.getStorageList()) {
		if (temp.isSameType(item)) {
			stack = temp;
			break;
		}
	}
	return stack;
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:11,代码来源:TileEntityMEBridge.java


示例7: wrap

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
/**
 * Wraps the specified fluid monitor and energy grid.
 *
 * @param fluidMonitor
 * Fluid monitor to listen to
 * @param energyGrid
 * Energy grid to extract power from
 * @param validationToken
 * Used to validate the state of the fluid listener, can not be null
 */
public void wrap( final IMEMonitor<IAEFluidStack> fluidMonitor, final IEnergyGrid energyGrid, final Object validationToken )
{
	// Ensure the token is not null
	if( validationToken != null )
	{
		// Set the token
		this.token = new WeakReference<Object>( validationToken );
	}
	else
	{
		// Throw exception
		throw new NullPointerException( "Validation Token Can Not Be Null" );
	}

	// Set the fluid monitor
	this.fluidMonitor = fluidMonitor;

	// Set the energy grid
	this.energyGrid = energyGrid;

	// Add listener
	this.fluidMonitor.addListener( this, this.token );

	// Mark that the cache needs to be updated
	this.cacheNeedsUpdate = true;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:37,代码来源:EssentiaMonitor.java


示例8: getItemMonitor

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
/**
 * Gets the AE item monitor for the grid.
 *
 * @return Monitor if valid grid, null otherwise.
 */
public IMEMonitor<IAEItemStack> getItemMonitor()
{
	// Get the storage grid
	IStorageGrid storageGrid = this.getStorageGrid();

	// Do we have a storage grid?
	if( storageGrid == null )
	{
		return null;
	}

	// Return the storage grid's item monitor.
	return storageGrid.getItemInventory();
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:20,代码来源:AEPartGridBlock.java


示例9: depositStack

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
/**
 * Attempts to deposit the itemstack into the AE system.
 * The {@code stack.stacksize} will change according to how many items were left over after the deposit.
 *
 * @param stack
 */
public void depositStack( final ItemStack stack )
{
	// Get the item monitor
	IMEMonitor<IAEItemStack> monitor = this.getItemInventory();
	if( monitor == null )
	{
		return;
	}

	// Create the AE stack
	IAEItemStack aeStack = AEApi.instance().storage().createItemStack( stack );

	// Set size
	int depositSize = Math.min( stack.stackSize, this.maxItemRate );
	aeStack.setStackSize( depositSize );

	// Deposit
	IAEItemStack rejected = AEApi.instance().storage().poweredInsert( this.getEnergyGrid(), monitor, aeStack, this.actionSource );
	if( rejected != null )
	{
		depositSize -= (int)rejected.getStackSize();
	}

	// Reduce stack by number of items deposited
	stack.stackSize -= depositSize;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:33,代码来源:AIAENetworkGolem.java


示例10: getNewMonitor

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
@Override
protected IMEEssentiaMonitor getNewMonitor()
{
	try
	{
		IMEInventoryHandler<IAEFluidStack> handler = null;

		// Get the chest handler
		List<IMEInventoryHandler> hostCellArray = this.hostChest.getCellArray( StorageChannel.FLUIDS );
		if( hostCellArray.size() > 0 )
		{
			handler = hostCellArray.get( 0 );
		}

		// Get the monitor
		if( handler != null )
		{
			// Create the essentia monitor
			return new EssentiaMonitor( (IMEMonitor<IAEFluidStack>)handler, this.hostChest.getProxy().getEnergy(), this );
		}
	}
	catch( Exception e )
	{
		e.printStackTrace();
	}

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


示例11: exportItem

import appeng.api.storage.IMEMonitor; //导入依赖的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


示例12: MENetworkStorageEvent

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
public MENetworkStorageEvent(IMEMonitor o, StorageChannel chan) {
	monitor = o;
	channel = chan;
}
 
开发者ID:amadornes,项目名称:Framez,代码行数:5,代码来源:MENetworkStorageEvent.java


示例13: MENetworkStorageEvent

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
public MENetworkStorageEvent(IMEMonitor o, StorageChannel chan) {
	this.monitor = o;
	this.channel = chan;
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:5,代码来源:MENetworkStorageEvent.java


示例14: MENetworkStorageEvent

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
public MENetworkStorageEvent(IMEMonitor o, StorageChannel chan) {
    monitor = o;
    channel = chan;
}
 
开发者ID:AgileMods,项目名称:MateriaMuto,代码行数:5,代码来源:MENetworkStorageEvent.java


示例15: updateCacheToMatchNetwork

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
/**
 * Add in any craftable aspects
 */
@Override
protected void updateCacheToMatchNetwork()
{
	// Call super
	super.updateCacheToMatchNetwork();

	// Is the network powered?
	if( !this.energyGrid.isNetworkPowered() )
	{
		return;
	}

	// Get the item monitor
	IStorageGrid storage = (IStorageGrid)this.internalGrid.getCache( IStorageGrid.class );
	IMEMonitor<IAEItemStack> itemMonitor = storage.getItemInventory();

	// Get stored items
	IItemList<IAEItemStack> storedItems = itemMonitor.getStorageList();
	if( ( storedItems == null ) || ( storedItems.size() == 0 ) )
	{
		return;
	}

	// Create the aspect list
	HashSet<Aspect> craftableAspects = new HashSet<Aspect>();

	// Check each item for craftability and type
	for( IAEItemStack stack : storedItems )
	{
		if( stack == null )
		{
			continue;
		}

		// Is the stack craftable, has NBT tag, and is a crafting aspect?
		if( stack.isCraftable() && stack.hasTagCompound() && ( stack.getItem() instanceof ItemCraftingAspect ) )
		{
			// Get the aspect
			Aspect aspect = ItemCraftingAspect.getAspect( stack.getTagCompound().getNBTTagCompoundCopy() );
			if( aspect != null )
			{
				// Add the aspect
				craftableAspects.add( aspect );
			}

		}
	}

	// Anything added?
	if( craftableAspects.size() > 0 )
	{
		this.setCraftableAspects( craftableAspects );
	}

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


示例16: getFluidInventory

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory()
{
	// Ignored
	return null;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:7,代码来源:PartEssentiaTerminal.java


示例17: getItemInventory

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
@Override
public IMEMonitor<IAEItemStack> getItemInventory()
{
	return this.getGridBlock().getItemMonitor();
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:6,代码来源:PartEssentiaTerminal.java


示例18: extractFluid

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
/**
 * Extracts fluids from the network.
 *
 * @param target
 * @return
 */
public FluidStack extractFluid( final FluidStack target )
{
	// Get the fluid monitor
	IMEMonitor<IAEFluidStack> monitor = this.getFluidInventory();
	if( monitor == null )
	{
		return null;
	}

	// Get power grid
	IEnergyGrid eGrid = this.getEnergyGrid();
	if( eGrid == null )
	{
		return null;
	}

	// Calculate request size
	long requestSize = Math.min( target.amount, this.maxFluidRate );

	// Calculate power required
	double pwrReq = requestSize / 100;
	if( eGrid.extractAEPower( pwrReq, Actionable.SIMULATE, PowerMultiplier.CONFIG ) < pwrReq )
	{
		// Not enough power
		return null;
	}

	// Create the fluid stack
	IAEFluidStack aeRequest = AEApi.instance().storage().createFluidStack( target );

	// Set size
	aeRequest.setStackSize( requestSize );

	// Extract
	IAEFluidStack extracted = monitor.extractItems( aeRequest, Actionable.MODULATE, this.actionSource );
	if( extracted == null )
	{
		return null;
	}

	// Take power
	pwrReq = extracted.getStackSize() / 100;
	eGrid.extractAEPower( pwrReq, Actionable.MODULATE, PowerMultiplier.CONFIG );

	return extracted.getFluidStack();

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


示例19: MENetworkStorageEvent

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
public MENetworkStorageEvent( IMEMonitor o, StorageChannel chan )
{
	this.monitor = o;
	this.channel = chan;
}
 
开发者ID:MineMaarten,项目名称:PneumaticCraft,代码行数:6,代码来源:MENetworkStorageEvent.java


示例20: EssentiaMonitor

import appeng.api.storage.IMEMonitor; //导入依赖的package包/类
/**
 * Wraps the specified fluid monitor and energy grid.
 *
 * @param fluidMonitor
 * Fluid monitor to listen to
 * @param energyGrid
 * Energy grid to extract power from
 * @param validationToken
 * Used to validate the state of the fluid listener, can not be null
 */
public EssentiaMonitor( final IMEMonitor<IAEFluidStack> fluidMonitor, final IEnergyGrid energyGrid, final Object validationToken )
{
	// Call default constructor
	this();

	// Call wrap
	this.wrap( fluidMonitor, energyGrid, validationToken );
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:19,代码来源:EssentiaMonitor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JobUtil类代码示例发布时间:2022-05-23
下一篇:
Java Quint类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap