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


Java Actionable.MODULATE属性代码示例

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


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

示例1: addEssentia

@Override
public int addEssentia( final Aspect aspect, final int amount, final ForgeDirection side, final Actionable mode )
{
	// Assume its all rejected
	long rejectedAmount = amount;

	// Ensure we have a monitor
	if( this.getEssentiaMonitor() )
	{
		// Inject essentia
		rejectedAmount = this.monitor.injectEssentia( aspect, amount, mode, this.getMachineSource(), true );
	}

	// Calculate the accepted amount
	long acceptedAmount = amount - rejectedAmount;

	if( ( mode == Actionable.MODULATE ) && ( acceptedAmount > 0 ) )
	{
		this.tickRate = TileEssentiaProvider.TICK_RATE_URGENT;
	}

	return (int)acceptedAmount;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:23,代码来源:TileEssentiaProvider.java

示例2: extractEssentia

@Override
public long extractEssentia( final Aspect aspect, final long amount, final Actionable mode, final BaseActionSource source, final boolean powered )
{
	if( powered )
	{
		// Simulate power extraction
		double powerRequest = EssentiaMonitor.AE_PER_ESSENTIA * amount;
		double powerReceived = this.energyGrid.extractAEPower( powerRequest, Actionable.SIMULATE, PowerMultiplier.CONFIG );

		// Was enough power extracted?
		if( powerReceived < powerRequest )
		{
			// Not enough power
			return 0;
		}
	}

	// Extract
	long extractedAmount = this.internalMonitor.extractEssentia( aspect, amount, mode, source, false );

	// Extract power if modulating
	if( ( extractedAmount > 0 ) && ( powered ) && ( mode == Actionable.MODULATE ) )
	{
		this.energyGrid.extractAEPower( EssentiaMonitor.AE_PER_ESSENTIA * extractedAmount, Actionable.MODULATE, PowerMultiplier.CONFIG );
	}

	return extractedAmount;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:28,代码来源:EssentiaPassThroughMonitor.java

示例3: injectEssentia

@Override
public long injectEssentia( final Aspect aspect, final long amount, final Actionable mode, final BaseActionSource source, final boolean powered )
{
	if( powered )
	{
		// Simulate power extraction
		double powerRequest = EssentiaMonitor.AE_PER_ESSENTIA * amount;
		double powerReceived = this.energyGrid.extractAEPower( powerRequest, Actionable.SIMULATE, PowerMultiplier.CONFIG );

		// Was enough power extracted?
		if( powerReceived < powerRequest )
		{
			// Not enough power
			return 0;
		}
	}

	// Inject
	long rejectedAmount = this.internalMonitor.injectEssentia( aspect, amount, mode, source, false );
	long injectedAmount = amount - rejectedAmount;

	// Extract power if modulating
	if( ( injectedAmount > 0 ) && ( powered ) && ( mode == Actionable.MODULATE ) )
	{
		this.energyGrid.extractAEPower( EssentiaMonitor.AE_PER_ESSENTIA * injectedAmount, Actionable.MODULATE, PowerMultiplier.CONFIG );
	}

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

示例4: extractFromContainer

/**
 * Extracts the specified aspect and amount from the container.
 *
 * @param container
 * @param amountToDrain
 * @param aspectToDrain
 * @param mode
 * @return The amount extracted.
 */
public long extractFromContainer( final IAspectContainer container, int amountToDrain, final Aspect aspectToDrain, final Actionable mode )
{

	// Is the request empty?
	if( amountToDrain == 0 )
	{
		// Empty request
		return 0;
	}

	// Is the container whitelisted?
	if( !this.perms.canExtractFromAspectContainerTile( container ) )
	{
		// Not whitelisted
		return 0;
	}

	// Get how much is in the container
	int containerAmount = container.getAspects().getAmount( aspectToDrain );

	// Is the container empty?
	if( containerAmount == 0 )
	{
		// Empty container, or does not contain the wanted aspect
		return 0;
	}
	// Is the drain for more than is in the container?
	if( amountToDrain > containerAmount )
	{
		amountToDrain = containerAmount;
	}

	// Are we really draining, or just simulating?
	if( mode == Actionable.MODULATE )
	{
		container.takeFromContainer( aspectToDrain, amountToDrain );
	}

	// Return how much was drained
	return amountToDrain;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:50,代码来源:EssentiaTileContainerHelper.java

示例5: injectEssentiaIntoContainer

/**
 * Attempts to inject essentia into the container.
 * Returns the amount that was injected.
 *
 * @param container
 * @param amountToFill
 * @param aspectToFill
 * @param mode
 * @return
 */
public long injectEssentiaIntoContainer( final IAspectContainer container, int amountToFill, final Aspect aspectToFill, final Actionable mode )
{
	// Is the container whitelisted?
	if( !this.perms.canInjectToAspectContainerTile( container ) )
	{
		// Not whitelisted
		return 0;
	}

	// Get the aspect in the container
	IAspectStack storedEssentia = this.getAspectStackFromContainer( container );

	// Match types on jars
	if( ( storedEssentia != null ) && ( container instanceof TileJarFillable ) )
	{
		// Do the aspects match?
		if( aspectToFill != storedEssentia.getAspect() )
		{
			// Aspects do not match;
			return 0;
		}
	}
	else if( !( container.doesContainerAccept( aspectToFill ) ) )
	{
		// Container will not accept this aspect
		return 0;
	}

	// Get how much the container can hold
	int containerCurrentCapacity = this.getContainerCapacity( container ) - this.getContainerStoredAmount( container );

	// Is there more to fill than the container will hold?
	if( amountToFill > containerCurrentCapacity )
	{
		amountToFill = containerCurrentCapacity;
	}

	// Are we really filling, or simulating?
	if( mode == Actionable.MODULATE )
	{
		// Attempt to inject the full amount
		int remaining = container.addToContainer( aspectToFill, amountToFill );

		// Subtract any that could not be injected
		amountToFill -= remaining;
	}

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

示例6: injectEssentia

@Override
public long injectEssentia( final Aspect aspect, final long amount, final Actionable mode, final BaseActionSource source, final boolean powered )
{
	// Call super
	long amountRejected = super.injectEssentia( aspect, amount, mode, source, powered );

	if( ( mode == Actionable.MODULATE ) && ( amountRejected < amount ) )
	{
		// Get the crafting grid
		ICraftingGrid craftingGrid = this.internalGrid.getCache( ICraftingGrid.class );

		// Get the CPU list
		ImmutableSet<ICraftingCPU> cpus = craftingGrid.getCpus();

		// Are there any crafting CPU's?
		if( cpus.size() > 0 )
		{
			// Set the aspect
			ItemCraftingAspect.setAspect( this.craftingAspectItem, aspect );

			// Delay creating this as long as possible
			IAEItemStack aspectAEItem = null;

			// Set the amounts
			long amountToInject = amount - amountRejected;

			// Are any CPU's waiting for this?
			for( ICraftingCPU cpu : cpus )
			{
				// Is the cpu crafting, and is it a cluster?
				if( cpu.isBusy() && ( cpu instanceof CraftingCPUCluster ) )
				{
					if( aspectAEItem == null )
					{
						// Create AE version
						aspectAEItem = AEApi.instance().storage().createItemStack( this.craftingAspectItem );
						aspectAEItem.setStackSize( 1 );
					}

					// Cast
					CraftingCPUCluster cluster = (CraftingCPUCluster)cpu;

					// Is the cluster waiting for an aspect item?
					if( cluster.isMaking( aspectAEItem ) )
					{
						// Not a fan of the loop, but inject items doesn't return anything useful
						for( ; ( amountToInject > 0 ) && ( cluster.isBusy() ); --amountToInject )
						{
							// Inject the aspect item
							cluster.injectItems( aspectAEItem, mode, source );
						}

						// Has everything been accounted for?
						if( amountToInject == 0 )
						{
							// All done
							break;
						}
					}
				}
			}
		}
	}

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

示例7: extractEssentia

@Override
public long extractEssentia( final Aspect aspect, final long amount, final Actionable mode, final BaseActionSource source, final boolean powered )
{
	// Ensure the aspect is not null, and the amount is > 0
	if( ( aspect == null ) || ( amount <= 0 ) )
	{
		// Invalid arguments
		return 0;
	}

	// Get the gas form of the essentia
	GaseousEssentia essentiaGas;

	// Ensure there is a gas form of the aspect.
	if( ( essentiaGas = GaseousEssentia.getGasFromAspect( aspect ) ) == null )
	{
		// Unregistered aspect :(
		return 0;
	}

	if( powered )
	{
		// Simulate power extraction
		double powerRequest = EssentiaMonitor.AE_PER_ESSENTIA * amount;
		double powerReceived = this.energyGrid.extractAEPower( powerRequest, Actionable.SIMULATE, PowerMultiplier.CONFIG );

		// Was enough power extracted?
		if( powerReceived < powerRequest )
		{
			// Not enough power
			return 0;
		}
	}

	// Create the fluid request
	IAEFluidStack fluidRequest = EssentiaConversionHelper.INSTANCE.createAEFluidStackInEssentiaUnits( essentiaGas, amount );

	// Attempt the extraction
	IAEFluidStack fluidReceived = this.fluidMonitor.extractItems( fluidRequest, mode, source );

	// Was any fluid received?
	if( ( fluidReceived == null ) || ( fluidReceived.getStackSize() <= 0 ) )
	{
		// Fluid not found.
		return 0;
	}

	// Convert the received fluid into an aspect stack
	long extractedAmount = EssentiaConversionHelper.INSTANCE.convertFluidAmountToEssentiaAmount( fluidReceived.getStackSize() );

	// Extract power if modulating
	if( ( powered ) && ( mode == Actionable.MODULATE ) )
	{
		this.energyGrid.extractAEPower( EssentiaMonitor.AE_PER_ESSENTIA * extractedAmount, Actionable.MODULATE, PowerMultiplier.CONFIG );
	}

	return extractedAmount;

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

示例8: addEssentiaToCell

/**
 * Attempts to add the essentia to the cell
 *
 * @param aspect
 * @param Amount
 * @return Amount not stored
 */
private long addEssentiaToCell( final Aspect aspect, final long amount, final Actionable mode )
{
	// Calculate amount to store
	long amountToStore = Math.min( amount, this.totalEssentiaStorage - this.usedEssentiaStorage );

	// Ensure we can store any
	if( amountToStore == 0 )
	{
		// Cell is full
		return amount;
	}

	// Get the slot for this aspect
	int slotIndex = this.getSlotFor( aspect );

	// Ensure there is somewhere to put the essentia
	if( slotIndex == -1 )
	{
		return amount;
	}

	// Are we modulating?
	if( mode == Actionable.MODULATE )
	{
		// Get the slot
		IAspectStack stackToAddTo = this.storedEssentia[slotIndex];

		// Is the slot null?
		if( stackToAddTo == null )
		{
			// Create the stack
			stackToAddTo = new AspectStack( aspect, 0 );

			// Store it
			this.storedEssentia[slotIndex] = stackToAddTo;
		}

		// Add to the stack
		stackToAddTo.adjustStackSize( amountToStore );

		// Adjust the used amount
		this.usedEssentiaStorage += amountToStore;

		// Write the changes to the data tag
		this.writeStorageChanges( slotIndex, stackToAddTo );
	}

	// Return the amount we could not store
	return( amount - amountToStore );

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

示例9: extractEssentiaFromCell

/**
 * Attempts to extract essentia from the cell.
 *
 * @param aspect
 * @param amount
 * @param mode
 * @return Amount extracted.
 */
private long extractEssentiaFromCell( final Aspect aspect, final long amount, final Actionable mode )
{
	// Do we have this essentia stored?
	int slotIndex = this.getSlotFor( aspect );
	if( ( slotIndex == -1 ) || ( this.storedEssentia[slotIndex] == null ) )
	{
		// Not stored.
		return 0;
	}

	// Get the slot
	IAspectStack slotToExtractFrom = this.storedEssentia[slotIndex];

	// Calculate the amount to extract
	long amountToExtract = Math.min( slotToExtractFrom.getStackSize(), amount );

	// Are we modulating?
	if( mode == Actionable.MODULATE )
	{
		// Extract from the slot
		slotToExtractFrom.adjustStackSize( -amountToExtract );

		// Is the slot now empty?
		if( slotToExtractFrom.isEmpty() )
		{
			// Null it
			slotToExtractFrom = null;

			// Update the storage
			this.storedEssentia[slotIndex] = null;
		}

		// Adjust the used amount
		this.usedEssentiaStorage -= amountToExtract;

		// Sync the data tag
		this.writeStorageChanges( slotIndex, slotToExtractFrom );

	}

	return amountToExtract;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:50,代码来源:HandlerItemEssentiaCell.java

示例10: extractItems

/**
 * Extracts essentia from the container.
 * returns the number of items extracted, null
 */
@Override
public IAEFluidStack extractItems( final IAEFluidStack request, final Actionable mode, final BaseActionSource source )
{
	if( ( this.aspectContainer == null ) || ( request == null ) )
	{
		// Nothing to drain from, or empty request
		return null;
	}

	// Ensure the fluid is an essentia gas
	if( !this.isFluidEssentiaGas( request ) )
	{
		// Not essentia gas fluid.
		return null;
	}

	// Get the fluid stack from the request
	FluidStack toDrain = request.getFluidStack();

	// Can this gas be transfered?
	if( !this.canTransferGas( (GaseousEssentia)toDrain.getFluid() ) )
	{
		// Can not transfer this gas.
		return null;
	}

	// Simulate draining the container
	FluidStack drained = EssentiaTileContainerHelper.INSTANCE.extractFromContainer( this.aspectContainer, toDrain, Actionable.SIMULATE );

	// Was any drained?
	if( ( drained == null ) || ( drained.amount == 0 ) )
	{
		// None was drained from the container.
		return null;
	}

	// Convert the drain amount to essentia units
	int drainedAmount_EU = (int)EssentiaConversionHelper.INSTANCE.convertFluidAmountToEssentiaAmount( drained.amount );

	// Do we have the power to drain this?
	if( !this.partStorageBus.extractPowerForEssentiaTransfer( drainedAmount_EU, Actionable.SIMULATE ) )
	{
		// Not enough power
		return null;
	}

	// Are we modulating?
	if( mode == Actionable.MODULATE )
	{
		// Extract
		EssentiaTileContainerHelper.INSTANCE.extractFromContainer( this.aspectContainer, toDrain, Actionable.MODULATE );

		// Take power
		this.partStorageBus.extractPowerForEssentiaTransfer( drainedAmount_EU, Actionable.MODULATE );

		// Update cache
		this.adjustCache( ( (GaseousEssentia)toDrain.getFluid() ).getAspect(), -drainedAmount_EU );
	}

	// Copy the request
	IAEFluidStack extractedFluid = request.copy();

	// Set the amount extracted
	extractedFluid.setStackSize( drained.amount );

	return extractedFluid;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:71,代码来源:HandlerEssentiaStorageBusContainer.java

示例11: drainContainer

/**
 * Drains an essentia container item.
 *
 * @param container
 * @param actionSource
 * @param mode
 * @return The result of the drain. <AmountDrained, NewContainer>
 */
@Nullable
private ImmutablePair<Integer, ItemStack> drainContainer(	final ItemStack container, final BaseActionSource actionSource,
															final Actionable mode )
{
	// Ensure there is a container
	if( container == null )
	{
		return null;
	}

	// Get the fluid stack from the item
	IAspectStack containerEssentia = EssentiaItemContainerHelper.INSTANCE.getAspectStackFromContainer( container );

	// Ensure there is something to drain
	if( ( containerEssentia == null ) || containerEssentia.isEmpty() )
	{
		// Nothing to drain
		return null;
	}

	// Get the proposed drain amount.
	int proposedDrainAmount = (int)containerEssentia.getStackSize();

	// Do a network injection
	long rejectedAmount = this.essentiaMonitor.injectEssentia( containerEssentia.getAspect(), proposedDrainAmount, mode, actionSource,
		true );

	// Was any rejected?
	if( rejectedAmount > 0 )
	{
		// Decrease the proposed amount
		proposedDrainAmount -= (int)rejectedAmount;

		// Can the network accept any?
		if( proposedDrainAmount <= 0 )
		{
			// Network is full
			return null;
		}
	}

	// Adjust work counter
	if( mode == Actionable.MODULATE )
	{
		this.workCounter += proposedDrainAmount;
	}

	// Attempt to drain the container
	return EssentiaItemContainerHelper.INSTANCE.extractFromContainer( container, proposedDrainAmount );
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:58,代码来源:ContainerEssentiaCellTerminalBase.java

示例12: fillContainer

/**
 * Fills an essentia container item.
 *
 * @param withAspect
 * @param container
 * @param actionSource
 * @param mode
 * @return The result of the fill. <AmountFilled, NewContainer>
 */
@Nullable
private ImmutablePair<Integer, ItemStack> fillContainer(	final Aspect withAspect, final ItemStack container,
															final BaseActionSource actionSource, final Actionable mode )
{
	// Ensure there is an aspect
	if( withAspect == null )
	{
		return null;
	}

	// Get the capacity of the container
	int containerCapacity = EssentiaItemContainerHelper.INSTANCE.getContainerCapacity( container );

	// Can the container hold essentia?
	if( containerCapacity == 0 )
	{
		// Invalid container
		return null;
	}

	// Do an extraction from the network
	long extractedAmount = this.essentiaMonitor.extractEssentia( withAspect, containerCapacity, mode, actionSource, true );

	// Was anything extracted?
	if( extractedAmount <= 0 )
	{
		// Gas is not present on network.
		return null;
	}

	// Calculate the proposed amount, based on how much we need and how much
	// is available
	int proposedFillAmount = (int)Math.min( containerCapacity, extractedAmount );

	// Adjust work counter
	if( mode == Actionable.MODULATE )
	{
		this.workCounter += proposedFillAmount;
	}

	// Create a new container filled to the proposed amount
	return EssentiaItemContainerHelper.INSTANCE.injectIntoContainer( container,
		new AspectStack( withAspect, proposedFillAmount ) );
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:53,代码来源:ContainerEssentiaCellTerminalBase.java

示例13: addEssentia

/**
 * Adds essentia to the buffer.
 *
 * @param aspect
 * @param amount
 * @param mode
 * @return
 */
@Override
protected int addEssentia( final Aspect aspect, final int amount, final Actionable mode )
{
	// Validate essentia type
	if( ( this.hasStoredEssentia() ) && ( this.storedEssentia.getAspect() != aspect ) )
	{
		// Essentia type does not match
		return 0;
	}

	// Get how much is stored, and the aspect
	int storedAmount = ( this.storedEssentia == null ? 0 : (int)this.storedEssentia.getStackSize() );
	Aspect storedAspect = ( this.storedEssentia == null ? null : this.storedEssentia.getAspect() );

	// Calculate how much to be stored
	int addedAmount = Math.min( amount, TileEVCBase.MAX_ESSENTIA_STORED - storedAmount );

	if( ( addedAmount > 0 ) && ( mode == Actionable.MODULATE ) )
	{
		// Create the stack if needed
		if( storedAspect == null )
		{
			this.storedEssentia = new AspectStack( aspect, 0 );
		}
		else
		{
			this.storedEssentia.setAspect( aspect );
		}

		// Add to the amount
		this.storedEssentia.adjustStackSize( addedAmount );

		// Mark for update
		this.markForUpdate();

		// Mark for save
		this.markDirty();
	}

	return addedAmount;
}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:49,代码来源:TileEssentiaVibrationChamber.java


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