Package appeng.api.networking.energy

Examples of appeng.api.networking.energy.IEnergyGrid


  private static boolean isPowered(IGrid grid)
  {
    if ( grid == null )
      return false;

    IEnergyGrid eg = grid.getCache( IEnergyGrid.class );
    return eg.isNetworkPowered();
  }
View Full Code Here


  public IEnergyGrid getEnergy() throws GridAccessException
  {
    IGrid grid = getGrid();
    if ( grid == null )
      throw new GridAccessException();
    IEnergyGrid eg = grid.getCache( IEnergyGrid.class );
    if ( eg == null )
      throw new GridAccessException();
    return eg;
  }
View Full Code Here

        if ( te instanceof IGridHost )
        {
          IGridNode node = ((IGridHost) te).getGridNode( ForgeDirection.getOrientation( side ) );
          if ( node != null && node.getGrid() != null )
          {
            IEnergyGrid eg = node.getGrid().getCache( IEnergyGrid.class );
            outputMsg( player, "GridEnergy: " + eg.getStoredPower() + " : " + eg.getEnergyDemand( Double.MAX_VALUE ) );
          }
        }
      }
    }
    return true;
View Full Code Here

        int z = te.zCoord + side.offsetZ;

        Block blk = w.getBlock( x, y, z );

        IStorageGrid storage = proxy.getStorage();
        IEnergyGrid energy = proxy.getEnergy();

        Material mat = blk.getMaterial();
        boolean ignore = mat == Material.air || mat == Material.lava || mat == Material.water || mat.isLiquid() || blk == Blocks.bedrock
            || blk == Blocks.end_portal || blk == Blocks.end_portal_frame || blk == Blocks.command_block;

        if ( !ignore )
        {
          if ( !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) )
          {
            float hardness = blk.getBlockHardness( w, x, y, z );
            if ( hardness >= 0.0 )
            {
              ItemStack[] out = Platform.getBlockDrops( w, x, y, z );
              float total = 1 + hardness;
              for (ItemStack is : out)
                total += is.stackSize;

              boolean hasPower = energy.extractAEPower( total, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > total - 0.1;
              if ( hasPower )
              {
                if ( eatForReal )
                {
                  energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG );
                  w.setBlock( x, y, z, Platform.air, 0, 3 );

                  AxisAlignedBB box = AxisAlignedBB.getBoundingBox( x - 0.2, y - 0.2, z - 0.2, x + 1.2, y + 1.2, z + 1.2 );
                  for (Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ))
                  {
View Full Code Here

  private void storeBuffer()
  {
    try
    {
      IStorageGrid storage = proxy.getStorage();
      IEnergyGrid energy = proxy.getEnergy();

      while (!Buffer.isEmpty())
      {
        IAEItemStack storedItem = Buffer.pop();
        storedItem = Platform.poweredInsert( energy, storage.getItemInventory(), storedItem, mySrc );
View Full Code Here

    ItemStack cell = getStackInSlot( 0 );
    if ( isSpatialCell( cell ) && getStackInSlot( 1 ) == null )
    {
      IGrid gi = gridProxy.getGrid();
      IEnergyGrid energy = gridProxy.getEnergy();

      ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();

      SpatialPylonCache spc = gi.getCache( ISpatialCache.class );
      if ( spc.hasRegion() && spc.isValidRegion() )
      {
        double req = spc.requiredPower();
        double pr = energy.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG );
        if ( Math.abs( pr - req ) < req * 0.001 )
        {
          MENetworkEvent res = gi.postEvent( new MENetworkSpatialEvent( this, req ) );
          if ( !res.isCanceled() )
          {
            TransitionResult tr = sc.doSpatialTransition( cell, worldObj, spc.getMin(), spc.getMax(), true );
            if ( tr.success )
            {
              energy.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
              setInventorySlotContents( 0, null );
              setInventorySlotContents( 1, cell );
            }
          }
        }
View Full Code Here

  @Override
  protected double extractAEPower(double amt, Actionable mode)
  {
    double stash = 0.0;

    IEnergyGrid eg;
    try
    {
      eg = gridProxy.getEnergy();
      stash = eg.extractAEPower( amt, mode, PowerMultiplier.ONE );
      if ( stash >= amt )
        return stash;
    }
    catch (GridAccessException e)
    {
View Full Code Here

        IGrid grid = node.getGrid();
        if ( grid == null )
          return;

        IStorageGrid inv = grid.getCache( IStorageGrid.class );
        IEnergyGrid energy = grid.getCache( IEnergyGrid.class );
        ISecurityGrid security = grid.getCache( ISecurityGrid.class );
        IInventory craftMatrix = cct.getInventoryByName( "crafting" );

        Actionable realForFake = cct.useRealItems() ? Actionable.MODULATE : Actionable.SIMULATE;
View Full Code Here

  {
    double acquiredPower = 0;

    try
    {
      IEnergyGrid eg = proxy.getEnergy();
      acquiredPower += eg.extractAEPower( amt - acquiredPower, mode, seen );
    }
    catch (GridAccessException e)
    {
      // :P
    }

    try
    {
      IEnergyGrid eg = outerProxy.getEnergy();
      acquiredPower += eg.extractAEPower( amt - acquiredPower, mode, seen );
    }
    catch (GridAccessException e)
    {
      // :P
    }
View Full Code Here

  public double injectAEPower(double amt, Actionable mode, Set<IEnergyGrid> seen)
  {

    try
    {
      IEnergyGrid eg = proxy.getEnergy();
      if ( !seen.contains( eg ) )
        return eg.injectAEPower( amt, mode, seen );
    }
    catch (GridAccessException e)
    {
      // :P
    }

    try
    {
      IEnergyGrid eg = outerProxy.getEnergy();
      if ( !seen.contains( eg ) )
        return eg.injectAEPower( amt, mode, seen );
    }
    catch (GridAccessException e)
    {
      // :P
    }
View Full Code Here

TOP

Related Classes of appeng.api.networking.energy.IEnergyGrid

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.