本文整理汇总了Java中appeng.api.networking.IGridNode类的典型用法代码示例。如果您正苦于以下问题:Java IGridNode类的具体用法?Java IGridNode怎么用?Java IGridNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IGridNode类属于appeng.api.networking包,在下文中一共展示了IGridNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockPlacedBy
import appeng.api.networking.IGridNode; //导入依赖的package包/类
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
if (world.isRemote) {
return;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TileAERuneAssembler) {
TileAERuneAssembler tileC = (TileAERuneAssembler) tile;
tileC.getProxy().onReady();
IGridNode node = tileC.getGridNode(ForgeDirection.UNKNOWN);
if (entity != null && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
node.setPlayerID(AEApi.instance().registries().players().getID(player));
}
node.updateState();
}
}
示例2: onBlockPlacedBy
import appeng.api.networking.IGridNode; //导入依赖的package包/类
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
if (world.isRemote) {
return;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TileAEDaisy) {
TileAEDaisy tileC = (TileAEDaisy) tile;
tileC.getProxy().onReady();
IGridNode node = tileC.getGridNode(ForgeDirection.UNKNOWN);
if (entity != null && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
node.setPlayerID(AEApi.instance().registries().players().getID(player));
}
node.updateState();
}
}
示例3: getTotalStored
import appeng.api.networking.IGridNode; //导入依赖的package包/类
public double getTotalStored() {
double nodePower = 0;
if (node != null) {
for (IGridNode n : node.getGrid().getNodes()) {
if (n != node) {
IGridHost host = n.getGridBlock().getMachine();
if (host instanceof IAEPowerStorage) {
IAEPowerStorage storage = (IAEPowerStorage) host;
if (storage.isAEPublicPowerStorage()
&& (storage.getPowerFlow() == AccessRestriction.READ || storage.getPowerFlow() == AccessRestriction.READ_WRITE))
nodePower += storage.getAECurrentPower();
}
}
}
}
return Math.min(getEnergyBuffer() + nodePower, getEnergyBufferSize());// FIXME
}
示例4: addNode
import appeng.api.networking.IGridNode; //导入依赖的package包/类
@Override
public void addNode( final IGridNode gridNode, final IGridHost machine )
{
// Does the node wish to watch for changes?
if( machine instanceof IEssentiaWatcherHost )
{
// Cast
IEssentiaWatcherHost host = (IEssentiaWatcherHost)machine;
// Create the watcher
EssentiaWatcher watcher = new EssentiaWatcher( this.essentiaWatcherManger, host );
// Add to the watcher manager
this.essentiaWatcherManger.addWatcher( gridNode, watcher );
// Inform the host it has a watcher
host.updateWatcher( watcher );
}
}
示例5: removeWatcher
import appeng.api.networking.IGridNode; //导入依赖的package包/类
/**
* Removes a watcher.
*
* @param node
*/
public void removeWatcher( final IGridNode node )
{
// Get the watcher
IEssentiaWatcher watcher = this.watchers.get( node );
if( watcher != null )
{
// Clear the watcher
watcher.clear();
// Remove the watcher
this.watchers.remove( node );
// Is the list empty?
if( this.watchers.isEmpty() )
{
// Ensure the watched aspects is also empty
this.watchedAspects.clear();
// Stop listening
this.gridCache.removeListener( this );
this.isListeningForChanges = false;
}
}
}
示例6: onBlockPreDestroy
import appeng.api.networking.IGridNode; //导入依赖的package包/类
@Override
public void onBlockPreDestroy(World world, int x, int y, int z, int meta) {
if (world.isRemote)
return;
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null) {
if (tile instanceof TileAERuneAssembler) {
IGridNode node = ((TileAERuneAssembler) tile).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
node.destroy();
}
}
}
}
示例7: onBlockPreDestroy
import appeng.api.networking.IGridNode; //导入依赖的package包/类
@Override
public void onBlockPreDestroy(World world, int x, int y, int z, int meta) {
if (world.isRemote)
return;
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null) {
if (tile instanceof TileAEDaisy) {
IGridNode node = ((TileAEDaisy) tile).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
node.destroy();
}
}
}
}
示例8: getGridNode
import appeng.api.networking.IGridNode; //导入依赖的package包/类
@Override
public IGridNode getGridNode(ForgeDirection dir) {
// if (getWorld() != null && !getWorld().isRemote) {
// if (node == null)
// node = AEApi.instance().createGridNode(this);
// node.updateState();
// }
return node;
}
示例9: getTiles
import appeng.api.networking.IGridNode; //导入依赖的package包/类
private List<TileEntity> getTiles(){
//List<ICellContainer> list = new ArrayList<ICellContainer>();
List<TileEntity> list = new ArrayList<TileEntity>();
//IGridNode gridNode = this.getGridNode(ForgeDirection.UNKNOWN);
try {
//IGrid grid = gridNode.getGrid();
IGrid grid = this.getProxy().getNode().getGrid();
for (Class<? extends IGridHost> clazz : grid.getMachinesClasses()) {
for (Class clazz2 : clazz.getInterfaces()) {
//NCLog.fatal("Passed Class 2");
//NCLog.fatal(clazz2);
if (clazz2 == IChestOrDrive.class) {
//NCLog.fatal("Passed If is IChestorDrive");
//NCLog.fatal(grid.getMachines(TileDrive.class));
for (IGridNode con : grid.getMachines(TileDrive.class)) {
//list.add((ICellContainer) con.getMachine());
list.add(getBaseTileEntity(con.getGridBlock().getLocation()));//.getMachine().getGridNode(ForgeDirection.UNKNOWN)
}
//for (IGridNode con : grid.getMachines(TileChest.class)) {
// list.add(getBaseTileEntity(con.getGridBlock().getLocation()));
//}
}
}
}
}catch (Exception e){}
return list;
}
示例10: removeNode
import appeng.api.networking.IGridNode; //导入依赖的package包/类
@Override
public void removeNode( final IGridNode gridNode, final IGridHost machine )
{
// Was the node an essentia watcher?
if( machine instanceof IEssentiaWatcherHost )
{
this.essentiaWatcherManger.removeWatcher( gridNode );
}
}
示例11: addWatcher
import appeng.api.networking.IGridNode; //导入依赖的package包/类
/**
* Adds a watcher.
*
* @param node
* @param watcher
*/
public void addWatcher( final IGridNode node, final IEssentiaWatcher watcher )
{
// Add the watcher
this.watchers.put( node, watcher );
// Is the manager not listening for changes?
if( !this.isListeningForChanges )
{
// Listen for changes
this.gridCache.addListener( this, this.gridCache.internalGrid );
this.isListeningForChanges = true;
}
}
示例12: locateAPsInRange
import appeng.api.networking.IGridNode; //导入依赖的package包/类
/**
* @param world
* @param x
* @param y
* @param z
* @param grid
* @return
*/
private static ArrayList<IWirelessAccessPoint> locateAPsInRange( final World world, final int x, final int y, final int z, final IGrid grid )
{
// Get all AP's on the grid
IMachineSet accessPoints = grid.getMachines( TileWireless.class );
if( accessPoints.isEmpty() )
{
return null;
}
// Create the list
ArrayList<IWirelessAccessPoint> aps = new ArrayList<IWirelessAccessPoint>();
// Loop over AP's and see if any are close enough to communicate with
for( IGridNode APNode : accessPoints )
{
// Get the AP
IWirelessAccessPoint AP = (IWirelessAccessPoint)APNode.getMachine();
// Is the AP active?
if( AP.isActive() )
{
// Close enough to the AP?
if( isAPInRange( AP.getLocation(), AP.getRange(), world, x, y, z ) )
{
aps.add( AP );
}
}
}
return aps;
}
示例13: tickingRequest
import appeng.api.networking.IGridNode; //导入依赖的package包/类
@Override
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
{
if( this.canDoWork() )
{
// Calculate the amount to transfer per second
int transferAmountPerSecond = this.getTransferAmountPerSecond();
// Calculate amount to transfer this operation
int transferAmount = (int)( transferAmountPerSecond * ( ticksSinceLastCall / 20.F ) );
// Clamp
if( transferAmount < MINIMUM_TRANSFER_PER_SECOND )
{
transferAmount = MINIMUM_TRANSFER_PER_SECOND;
}
else if( transferAmount > MAXIMUM_TRANSFER_PER_SECOND )
{
transferAmount = MAXIMUM_TRANSFER_PER_SECOND;
}
if( this.doWork( transferAmount ) )
{
return TickRateModulation.URGENT;
}
}
return TickRateModulation.IDLE;
}
示例14: getTickingRequest
import appeng.api.networking.IGridNode; //导入依赖的package包/类
/**
* Sets how often we would like ticks.
*/
@Override
public TickingRequest getTickingRequest( final IGridNode node )
{
// We would like a tick ever 20 MC ticks
return new TickingRequest( 20, 20, false, false );
}
示例15: tickingRequest
import appeng.api.networking.IGridNode; //导入依赖的package包/类
/**
* Called periodically by AE2. Passes the tick to the handler.
*/
@Override
public TickRateModulation tickingRequest( final IGridNode node, final int TicksSinceLastCall )
{
// Update the handler.
this.handler.tickingRequest( node, TicksSinceLastCall );
// Keep chugging along
return TickRateModulation.SAME;
}