本文整理汇总了Java中appeng.api.config.Actionable类的典型用法代码示例。如果您正苦于以下问题:Java Actionable类的具体用法?Java Actionable怎么用?Java Actionable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Actionable类属于appeng.api.config包,在下文中一共展示了Actionable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEssentia
import appeng.api.config.Actionable; //导入依赖的package包/类
@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;
}
示例2: extractPowerForEssentiaTransfer
import appeng.api.config.Actionable; //导入依赖的package包/类
/**
* Extracts power from the network proportional to the specified essentia
* amount.
*
* @param essentiaAmount
* @param mode
* @return
*/
public boolean extractPowerForEssentiaTransfer( final int essentiaAmount, final Actionable mode )
{
// Get the energy grid
IEnergyGrid eGrid = this.getGridBlock().getEnergyGrid();
// Ensure we have a grid
if( eGrid == null )
{
return false;
}
// Calculate amount of power to take
double powerDrain = EssentiaMonitor.AE_PER_ESSENTIA * essentiaAmount;
// Extract
return( eGrid.extractAEPower( powerDrain, mode, PowerMultiplier.CONFIG ) >= powerDrain );
}
示例3: insertEssentia
import appeng.api.config.Actionable; //导入依赖的package包/类
/**
* Inserts essentia into the network.
*
* @param aspect
* @param amount
* @return Amount injected
*/
public long insertEssentia( final Aspect aspect, final int amount )
{
// Get the essentia monitor
IMEEssentiaMonitor monitor = this.getEssentiaInventory();
if( monitor == null )
{
return 0;
}
// Calculate the amount to inject
int amountToInject = Math.min( amount, this.maxEssentiaRate );
// Attempt to inject
long amountRejected = monitor.injectEssentia( aspect, amountToInject, Actionable.MODULATE, this.actionSource, true );
// Return the amount that was injected
return amountToInject - amountRejected;
}
示例4: extractItems
import appeng.api.config.Actionable; //导入依赖的package包/类
/**
* Attempts to extract the gas from the sub-grid.
*/
@Override
public IAEFluidStack extractItems( final IAEFluidStack request, final Actionable mode, final BaseActionSource source )
{
// Is the fluid an essentia gas?
if( this.isFluidEssentiaGas( request ) )
{
if( this.handler != null )
{
// Extract the gas
IAEFluidStack extractedGas = this.handler.extractItems( request, mode, source );
return extractedGas;
}
}
return null;
}
示例5: injectItems
import appeng.api.config.Actionable; //导入依赖的package包/类
/**
* Attempts to inject the gas into the sub-network.
*/
@Override
public IAEFluidStack injectItems( final IAEFluidStack input, final Actionable mode, final BaseActionSource source )
{
// Is the fluid an essentia gas?
if( this.isFluidEssentiaGas( input ) )
{
if( this.handler != null )
{
// Inject the gas
IAEFluidStack remainingGas = this.handler.injectItems( input, mode, source );
return remainingGas;
}
}
return input;
}
示例6: extractItems
import appeng.api.config.Actionable; //导入依赖的package包/类
/**
* The creative cell can only provide essentia based on its parition table.
*/
@Override
public IAEFluidStack extractItems( final IAEFluidStack request, final Actionable mode, final BaseActionSource src )
{
// Ensure there is a request, and that it is an essentia gas
if( ( request != null ) && ( request.getFluid() != null ) && ( request.getFluid() instanceof GaseousEssentia ) )
{
// Get the aspect of the essentia
Aspect requestAspect = ( (GaseousEssentia)request.getFluid() ).getAspect();
// Is the cell partitioned for this aspect?
if( ( requestAspect != null ) && ( this.partitionAspects.contains( requestAspect ) ) )
{
return request.copy();
}
}
return null;
}
示例7: injectItems
import appeng.api.config.Actionable; //导入依赖的package包/类
@Override
public StackType injectItems(StackType input, Actionable mode, BaseActionSource src)
{
if ( mode == Actionable.SIMULATE )
return getHandler().injectItems( input, mode, src );
return monitorDifference(input.copy(), getHandler().injectItems(input, mode, src), false, src);
}
示例8: extractItems
import appeng.api.config.Actionable; //导入依赖的package包/类
@Override
public StackType extractItems(StackType request, Actionable mode, BaseActionSource src)
{
if ( mode == Actionable.SIMULATE )
return getHandler().extractItems( request, mode, src );
return monitorDifference(request.copy(), getHandler().extractItems(request, mode, src), true, src);
}
示例9: extractItems
import appeng.api.config.Actionable; //导入依赖的package包/类
@Override
public StackType extractItems(StackType request, Actionable mode, BaseActionSource src)
{
if ( mode == Actionable.SIMULATE )
return this.getHandler().extractItems( request, mode, src );
return this.monitorDifference(request.copy(), this.getHandler().extractItems(request, mode, src), true, src);
}
示例10: injectItems
import appeng.api.config.Actionable; //导入依赖的package包/类
@Override
public StackType injectItems(StackType input, Actionable mode, BaseActionSource src) {
if (mode == Actionable.SIMULATE) {
return getHandler().injectItems(input, mode, src);
}
return monitorDiffrence((StackType) input.copy(), getHandler().injectItems(input, mode, src), false, src);
}
示例11: extractItems
import appeng.api.config.Actionable; //导入依赖的package包/类
@Override
public StackType extractItems(StackType request, Actionable mode, BaseActionSource src) {
if (mode == Actionable.SIMULATE) {
return getHandler().extractItems(request, mode, src);
}
return monitorDiffrence((StackType) request.copy(), getHandler().extractItems(request, mode, src), true, src);
}
示例12: extractFromContainer
import appeng.api.config.Actionable; //导入依赖的package包/类
/**
* Extracts essentia from a container based on the specified fluid stack
* type and amount.
*
* @param container
* @param request
* @param mode
* @return
*/
public FluidStack extractFromContainer( final IAspectContainer container, final FluidStack request, final Actionable mode )
{
// Ensure there is a request
if( ( request == null ) || ( request.getFluid() == null ) || ( request.amount == 0 ) )
{
// No request
return null;
}
// Get the fluid
Fluid fluid = request.getFluid();
// Ensure it is a gas
if( !( fluid instanceof GaseousEssentia ) )
{
// Not a gas
return null;
}
// Get the gas's aspect
Aspect gasAspect = ( (GaseousEssentia)fluid ).getAspect();
// Get the amount to extract
long amountToDrain_EU = EssentiaConversionHelper.INSTANCE.convertFluidAmountToEssentiaAmount( request.amount );
// Extract
long extractedAmount_EU = this.extractFromContainer( container, (int)amountToDrain_EU, gasAspect, mode );
// Was any extracted?
if( extractedAmount_EU <= 0 )
{
// None extracted
return null;
}
// Return the extracted amount
return new FluidStack( fluid, (int)EssentiaConversionHelper.INSTANCE.convertEssentiaAmountToFluidAmount( extractedAmount_EU ) );
}
示例13: injectFluidIntoContainer
import appeng.api.config.Actionable; //导入依赖的package包/类
/**
* Attempts to inject the fluid into the container.
* Returns the amount that was injected in milibuckets.
*
* @param container
* @param fluidStack
* @param mode
* @return
*/
public long injectFluidIntoContainer( final IAspectContainer container, final IAEFluidStack fluidStack, final Actionable mode )
{
// Do we have an input?
if( fluidStack == null )
{
// No input
return 0;
}
// Is the container whitelisted?
if( !this.perms.canInjectToAspectContainerTile( container ) )
{
// Not whitelisted
return 0;
}
// Get the fluid.
Fluid fluid = fluidStack.getFluid();
// Ensure it is a gas
if( !( fluid instanceof GaseousEssentia ) )
{
// Not essentia gas
return 0;
}
// Get the aspect of the gas
Aspect gasAspect = ( (GaseousEssentia)fluid ).getAspect();
// Get the amount to fill
long amountToFill = EssentiaConversionHelper.INSTANCE.convertFluidAmountToEssentiaAmount( fluidStack.getStackSize() );
// Inject
long injectedAmount_EU = this.injectEssentiaIntoContainer( container, (int)amountToFill, gasAspect, mode );
return EssentiaConversionHelper.INSTANCE.convertEssentiaAmountToFluidAmount( injectedAmount_EU );
}
示例14: extractEssentia
import appeng.api.config.Actionable; //导入依赖的package包/类
@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;
}
示例15: injectEssentia
import appeng.api.config.Actionable; //导入依赖的package包/类
@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;
}