本文整理汇总了Java中appeng.api.networking.energy.IEnergyGrid类的典型用法代码示例。如果您正苦于以下问题:Java IEnergyGrid类的具体用法?Java IEnergyGrid怎么用?Java IEnergyGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEnergyGrid类属于appeng.api.networking.energy包,在下文中一共展示了IEnergyGrid类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEnergyGrid
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
public IEnergyGrid getEnergyGrid()
{
// Check AP
if( this.accessPoint == null )
{
return null;
}
try
{
// Get the energy grid
return this.accessPoint.getActionableNode().getGrid().getCache( IEnergyGrid.class );
}
catch( Exception e )
{
// Ignored
}
return null;
}
示例2: extractPowerForEssentiaTransfer
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的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: onGridCacheReady
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
@MENetworkEventSubscribe
public void onGridCacheReady( final MENetworkPostCacheConstruction event )
{
// Get the storage grid
IStorageGrid storage = (IStorageGrid)this.internalGrid.getCache( IStorageGrid.class );
// Wrap
this.wrap( storage.getFluidInventory(), (IEnergyGrid)this.internalGrid.getCache( IEnergyGrid.class ), this.internalGrid );
// Set the crafting watcher
storage.getItemInventory().addListener( this.craftingWatcher, this.internalGrid );
}
示例4: EssentiaPassThroughMonitor
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
public EssentiaPassThroughMonitor( final IMEEssentiaMonitor source, final IEnergyGrid energyGrid )
{
// Call super
super();
// Set the source
this.internalMonitor = source;
// Set the energy grid
this.energyGrid = energyGrid;
}
示例5: wrap
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的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;
}
示例6: getEnergyGrid
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
public IEnergyGrid getEnergyGrid()
{
// Get the grid
IGrid grid = this.getGrid();
// Ensure we have a grid
if( grid == null )
{
return null;
}
// Return the energy grid
return grid.getCache( IEnergyGrid.class );
}
示例7: isPowered
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
@Override
public boolean isPowered()
{
try
{
// Server side?
if( EffectiveSide.isServerSide() && ( this.gridBlock != null ) )
{
// Get the energy grid
IEnergyGrid eGrid = this.gridBlock.getEnergyGrid();
if( eGrid != null )
{
this.isPowered = eGrid.isNetworkPowered();
}
else
{
this.isPowered = false;
}
}
}
catch( Exception e )
{
// Network unavailable, return cached value.
}
return this.isPowered;
}
示例8: getEnergyGrid
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
protected IEnergyGrid getEnergyGrid(IGridHost host) {
return getCache(IEnergyGrid.class, host);
}
示例9: consumeVisFromVisNetwork
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
/**
* Requests that the interface drain vis from the relay
*
* @param digiVisAspect
* @param amount
* @return
*/
private int consumeVisFromVisNetwork( final Aspect digiVisAspect, final int amount )
{
// Get the relay
TileVisRelay visRelay = this.getRelay();
// Ensure there is a relay
if( visRelay == null )
{
return 0;
}
// Get the power grid
IEnergyGrid eGrid = this.getGridBlock().getEnergyGrid();
// Ensure we got the grid
if( eGrid == null )
{
return 0;
}
// Simulate a power drain
double drainedPower = eGrid.extractAEPower( PartVisInterface.POWER_PER_REQUESTED_VIS, Actionable.SIMULATE, PowerMultiplier.CONFIG );
// Ensure we got the power we need
if( drainedPower < PartVisInterface.POWER_PER_REQUESTED_VIS )
{
return 0;
}
// Ask it for vis
int amountReceived = visRelay.consumeVis( digiVisAspect, amount );
// Did we get any vis?
if( amountReceived > 0 )
{
// Drain the power
eGrid.extractAEPower( PartVisInterface.POWER_PER_REQUESTED_VIS, Actionable.MODULATE, PowerMultiplier.CONFIG );
}
// Return the amount we received
return amountReceived;
}
示例10: extractFluid
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的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();
}
示例11: extractAEPower
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
@Override
public double extractAEPower( final double amt, final Actionable mode, final Set<IEnergyGrid> seen )
{
return HandlerWirelessEssentiaTerminal.this.extractPower( amt, mode );
}
示例12: getEnergyDemand
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
@Override
public double getEnergyDemand( final double d, final Set<IEnergyGrid> seen )
{
// Ignored
return 0;
}
示例13: injectAEPower
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的package包/类
@Override
public double injectAEPower( final double amt, final Actionable mode, final Set<IEnergyGrid> seen )
{
// Ignored
return amt;
}
示例14: EssentiaMonitor
import appeng.api.networking.energy.IEnergyGrid; //导入依赖的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 );
}