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


Java IAEItemStack.getStackSize方法代码示例

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


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

示例1: getObjectFromStack

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
private Object getObjectFromStack(IAEItemStack stack, int flag) {
	HashMap<String, Object> map = new HashMap<String, Object>();
	String itemName = Item.itemRegistry.getNameForObject(stack.getItem());
	int meta = stack.getItemDamage();
	long amount = stack.getStackSize();
	String displayName = stack.getItemStack().getDisplayName();
	map.put("name", itemName);
	map.put("meta", meta);
	map.put("amount", amount);
	map.put("displayName", displayName);
	if (flag == 0) {
		return map;
	} else if (flag == 1) {
		if (stack.getStackSize() > 0)
			return map;
	} else if (flag == 2) {
		if (stack.isCraftable())
			return map;
	}
	return null;
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:22,代码来源:TileEntityMEBridge.java

示例2: sendItemWidgetClicked

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
/**
 * If the user has clicked on an item widget this will inform the server
 * so that the item can be extracted from the AE network.
 *
 * @param mouseX
 * @param mouseY
 * @param mouseButton
 */
private void sendItemWidgetClicked( final int mouseX, final int mouseY, final int mouseButton )
{
	for( int index = 0; index < this.widgetCount; ++index )
	{
		// Get the widget
		WidgetAEItem currentWidget = this.itemWidgets.get( index );

		// Is the mouse over this widget
		if( currentWidget.isMouseOverWidget( mouseX, mouseY ) )
		{
			// Get the AE itemstack this widget represents
			IAEItemStack widgetStack = currentWidget.getItemStack();

			// Did we get an item?
			if( widgetStack != null )
			{
				// Should the item be crafted?
				if( ( widgetStack.getStackSize() == 0 ) || ( mouseButton == ThEGuiHelper.MOUSE_BUTTON_WHEEL ) )
				{
					if( ( widgetStack.isCraftable() ) && ( mouseButton != ThEGuiHelper.MOUSE_BUTTON_RIGHT ) )
					{
						Packet_S_ArcaneCraftingTerminal.sendAutoCraft( this.player, widgetStack );
						return;
					}
				}

				// Let the server know the user is requesting an itemstack.
				Packet_S_ArcaneCraftingTerminal.sendExtract( this.player, widgetStack, mouseButton, GuiScreen.isShiftKeyDown() );
			}

			// Stop searching
			return;
		}
	}
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:44,代码来源:GuiArcaneCraftingTerminal.java

示例3: depositStack

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

示例4: mergeWithMENetwork

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
/**
 * Attempts to inject an itemstack into the ME network.
 * Adjusts the stack size of the specified itemstack according to
 * the results of the merger.
 *
 * @param itemStack
 * @return True if any amount was merged, False otherwise.
 */
private boolean mergeWithMENetwork( final ItemStack itemStack )
{
	// Attempt to place in the ME system
	IAEItemStack toInject = AEApi.instance().storage().createItemStack( itemStack );

	// Get what is left over after the injection
	IAEItemStack leftOver = this.monitor.injectItems( toInject, Actionable.MODULATE, this.playerSource );

	// Do we have any left over?
	if( ( leftOver != null ) && ( leftOver.getStackSize() > 0 ) )
	{
		// Did we inject any?
		if( leftOver.getStackSize() == toInject.getStackSize() )
		{
			// No injection occurred
			return false;
		}

		// Some was injected, adjust the slot stack size
		itemStack.stackSize = (int)leftOver.getStackSize();

		return true;
	}

	// All was injected
	itemStack.stackSize = 0;

	return true;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:38,代码来源:ContainerPartArcaneCraftingTerminal.java

示例5: sendSimulationInfo

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

示例6: setupAEResults

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
/**
 * Sets up all results, including container items.
 */
private void setupAEResults()
{
	// Ensure the ingredient list is made
	if( this.ingredientsAE == null )
	{
		this.setupAEIngredientList();
	}

	ArrayList<IAEItemStack> results = new ArrayList<IAEItemStack>();

	// Add any container items
	for( IAEItemStack stack : this.ingredientsAE )
	{
		if( stack == null )
		{
			continue;
		}

		// Container?
		if( stack.getItem().hasContainerItem( stack.getItemStack() ) )
		{
			results.add( AEApi.instance().storage().createItemStack( stack.getItem().getContainerItem( stack.getItemStack() ) ) );
		}

		// Multiplier?
		else if( stack.getStackSize() > 1 )
		{
			results.add( stack.copy().setStackSize( stack.getStackSize() - 1 ) );
		}
		// Primordial Pearl?
		else if( ( stack.getItem() instanceof ItemEldritchObject ) && ( stack.getItemDamage() == 3 ) )
		{
			results.add( stack );
		}

	}

	// Add result
	results.add( this.result );

	// Set the outputs
	this.allResults = results.toArray( new IAEItemStack[results.size()] );
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:47,代码来源:ArcaneCraftingPattern.java

示例7: onClientRequestDeposit

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
/**
 * A client player is requesting to deposit their held item
 * into the ME network.
 */
public void onClientRequestDeposit( final EntityPlayer player, final int mouseButton )
{
	// Ensure there is a player & monitor
	if( ( player == null ) || ( this.monitor == null ) )
	{
		return;
	}

	// Get what the player is holding
	ItemStack playerHolding = player.inventory.getItemStack();

	// Is the player holding anything?
	if( playerHolding == null )
	{
		return;
	}

	// Create the AE itemstack representation of the itemstack
	IAEItemStack toInjectStack = AEApi.instance().storage().createItemStack( playerHolding );

	// Was it a right click or wheel movement?
	boolean depositOne = ( mouseButton == ThEGuiHelper.MOUSE_BUTTON_RIGHT ) || ( mouseButton == ThEGuiHelper.MOUSE_WHEEL_MOTION );

	if( depositOne )
	{
		// Set stack size to 1
		toInjectStack.setStackSize( 1 );
	}

	// Attempt to inject
	IAEItemStack leftOverStack = this.monitor.injectItems( toInjectStack, Actionable.MODULATE, this.playerSource );

	// Was there anything left over?
	if( ( leftOverStack != null ) && ( leftOverStack.getStackSize() > 0 ) )
	{
		// Were we only trying to inject one?
		if( toInjectStack.getStackSize() == 1 )
		{
			// No changes made
			return;
		}

		// Set what was left over as the itemstack being held
		player.inventory.setItemStack( leftOverStack.getItemStack() );
	}
	else
	{
		// Are we only depositing one, and there was more than 1 item?
		if( ( depositOne ) && ( playerHolding.stackSize > 1 ) )
		{
			// Set the player holding one less
			playerHolding.stackSize-- ;
			player.inventory.setItemStack( playerHolding );

			// Set the leftover stack to match
			leftOverStack = AEApi.instance().storage().createItemStack( playerHolding );
		}
		else
		{
			// Set the player as holding nothing
			player.inventory.setItemStack( null );
		}
	}

	// Send the update to the client
	Packet_C_Sync.sendPlayerHeldItem( player, ( leftOverStack == null ? null : leftOverStack.getItemStack() ) );
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:72,代码来源:ContainerPartArcaneCraftingTerminal.java

示例8: requestCraftingReplenishment

import appeng.api.storage.data.IAEItemStack; //导入方法依赖的package包/类
/**
 * Attempts to extract an item from the network.
 * Used when crafting to replenish the crafting grid.
 *
 * @param itemStack
 * @return
 */
public ItemStack requestCraftingReplenishment( final ItemStack itemStack )
{
	if( this.monitor == null )
	{
		return null;
	}

	// Search the players inventory
	ItemStack replenishmentPlayer = this.takeItemFromPlayer( itemStack, 1 );
	if( replenishmentPlayer != null )
	{
		return replenishmentPlayer;
	}

	// Create the AE request stack
	IAEItemStack requestStack = AEApi.instance().storage().createItemStack( itemStack );

	// Set the request amount to one
	requestStack.setStackSize( 1 );

	// Attempt an extraction
	IAEItemStack replenishmentAE = this.monitor.extractItems( requestStack, Actionable.MODULATE, this.playerSource );

	// Did we get a replenishment?
	if( replenishmentAE != null )
	{
		return replenishmentAE.getItemStack();
	}

	// Did not get a replenishment, search for items that match.

	// Get a list of all items in the ME network
	IItemList<IAEItemStack> networkItems = this.monitor.getStorageList();

	// Search all items
	for( IAEItemStack potentialMatch : networkItems )
	{
		// Does the request match?
		if( this.doStacksMatch( requestStack, potentialMatch ) )
		{
			// Found a match
			requestStack = potentialMatch.copy();

			// Set the request amount to one
			requestStack.setStackSize( 1 );

			// Attempt an extraction
			replenishmentAE = this.monitor.extractItems( requestStack, Actionable.MODULATE, this.playerSource );

			// Did we get a replenishment?
			if( ( replenishmentAE != null ) && ( replenishmentAE.getStackSize() > 0 ) )
			{
				return replenishmentAE.getItemStack();
			}
		}

	}

	// No matches at all :(
	return null;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:69,代码来源:ContainerPartArcaneCraftingTerminal.java


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