Package appeng.api.storage.data

Examples of appeng.api.storage.data.IAEItemStack


  {

    if ( stack == null )
      return false;

    IAEItemStack failed = me.injectItems( AEItemStack.create( stack ), Actionable.SIMULATE, null );

    if ( failed == null )
      return true;
    return failed.getStackSize() != stack.stackSize;
  }
View Full Code Here


  public ItemStack shiftStoreItem(ItemStack input)
  {
    if ( powerSrc == null || cellInv == null )
      return input;
    IAEItemStack ais = Platform.poweredInsert( powerSrc, cellInv, AEApi.instance().storage().createItemStack( input ), mySrc );
    if ( ais == null )
      return null;
    return ais.getItemStack();
  }
View Full Code Here

      return;
    }

    // get target item.
    IAEItemStack slotItem = getTargetStack();

    switch (action)
    {
    case SHIFT_CLICK:
      if ( powerSrc == null || cellInv == null )
        return;

      if ( slotItem != null )
      {
        IAEItemStack ais = slotItem.copy();
        ItemStack myItem = ais.getItemStack();

        ais.setStackSize( myItem.getMaxStackSize() );

        InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
        myItem.stackSize = (int) ais.getStackSize();
        myItem = adp.simulateAdd( myItem );

        if ( myItem != null )
          ais.setStackSize( ais.getStackSize() - myItem.stackSize );

        ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
        if ( ais != null )
          adp.addItems( ais.getItemStack() );
      }
      break;
    case ROLL_DOWN:
      if ( powerSrc == null || cellInv == null )
        return;

      int releaseQty = 1;
      ItemStack isg = player.inventory.getItemStack();

      if ( isg != null && releaseQty > 0 )
      {
        IAEItemStack ais = AEApi.instance().storage().createItemStack( isg );
        ais.setStackSize( 1 );
        IAEItemStack extracted = ais.copy();

        ais = Platform.poweredInsert( powerSrc, cellInv, ais, mySrc );
        if ( ais == null )
        {
          InventoryAdaptor ia = new AdaptorPlayerHand( player );

          ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null );
          if ( fail == null )
            cellInv.extractItems( extracted, Actionable.MODULATE, mySrc );

          updateHeld( player );
        }
      }

      break;
    case ROLL_UP:
    case PICKUP_SINGLE:
      if ( powerSrc == null || cellInv == null )
        return;

      if ( slotItem != null )
      {
        int liftQty = 1;
        ItemStack item = player.inventory.getItemStack();

        if ( item != null )
        {
          if ( item.stackSize >= item.getMaxStackSize() )
            liftQty = 0;
          if ( !Platform.isSameItemPrecise( slotItem.getItemStack(), item ) )
            liftQty = 0;
        }

        if ( liftQty > 0 )
        {
          IAEItemStack ais = slotItem.copy();
          ais.setStackSize( 1 );
          ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
          if ( ais != null )
          {
            InventoryAdaptor ia = new AdaptorPlayerHand( player );

            ItemStack fail = ia.addItems( ais.getItemStack() );
            if ( fail != null )
              cellInv.injectItems( ais, Actionable.MODULATE, mySrc );

            updateHeld( player );
          }
        }
      }
      break;
    case PICKUP_OR_SET_DOWN:
      if ( powerSrc == null || cellInv == null )
        return;

      if ( player.inventory.getItemStack() == null )
      {
        if ( slotItem != null )
        {
          IAEItemStack ais = slotItem.copy();
          ais.setStackSize( ais.getItemStack().getMaxStackSize() );
          ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
          if ( ais != null )
            player.inventory.setItemStack( ais.getItemStack() );
          else
            player.inventory.setItemStack( null );
          updateHeld( player );
        }
      }
      else
      {
        IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
        ais = Platform.poweredInsert( powerSrc, cellInv, ais, mySrc );
        if ( ais != null )
          player.inventory.setItemStack( ais.getItemStack() );
        else
          player.inventory.setItemStack( null );
        updateHeld( player );
      }

      break;
    case SPLIT_OR_PLACE_SINGLE:
      if ( powerSrc == null || cellInv == null )
        return;

      if ( player.inventory.getItemStack() == null )
      {
        if ( slotItem != null )
        {
          IAEItemStack ais = slotItem.copy();
          long maxSize = ais.getItemStack().getMaxStackSize();
          ais.setStackSize( maxSize );
          ais = cellInv.extractItems( ais, Actionable.SIMULATE, mySrc );

          if ( ais != null )
          {
            long stackSize = Math.min( maxSize, ais.getStackSize() );
            ais.setStackSize( (stackSize + 1) >> 1 );
            ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
          }

          if ( ais != null )
            player.inventory.setItemStack( ais.getItemStack() );
          else
            player.inventory.setItemStack( null );
          updateHeld( player );
        }
      }
      else
      {
        IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
        ais.setStackSize( 1 );
        ais = Platform.poweredInsert( powerSrc, cellInv, ais, mySrc );
        if ( ais == null )
        {
          ItemStack is = player.inventory.getItemStack();
          is.stackSize--;
          if ( is.stackSize <= 0 )
            player.inventory.setItemStack( null );
          updateHeld( player );
        }
      }

      break;
    case CREATIVE_DUPLICATE:
      if ( player.capabilities.isCreativeMode && slotItem != null )
      {
        ItemStack is = slotItem.getItemStack();
        is.stackSize = is.getMaxStackSize();
        player.inventory.setItemStack( is );
        updateHeld( player );
      }
      break;
    case MOVE_REGION:

      if ( powerSrc == null || cellInv == null )
        return;

      if ( slotItem != null )
      {
        int playerInv = 9 * 4;
        for (int slotNum = 0; slotNum < playerInv; slotNum++)
        {
          IAEItemStack ais = slotItem.copy();
          ItemStack myItem = ais.getItemStack();

          ais.setStackSize( myItem.getMaxStackSize() );

          InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
          myItem.stackSize = (int) ais.getStackSize();
          myItem = adp.simulateAdd( myItem );

          if ( myItem != null )
            ais.setStackSize( ais.getStackSize() - myItem.stackSize );

          ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
          if ( ais != null )
            adp.addItems( ais.getItemStack() );
          else
            return;
        }
      }

View Full Code Here

    buttonList.add( cancel );
  }

  private long getTotal(IAEItemStack is)
  {
    IAEItemStack a = storage.findPrecise( is );
    IAEItemStack b = active.findPrecise( is );
    IAEItemStack c = pending.findPrecise( is );

    long total = 0;

    if ( a != null )
      total += a.getStackSize();

    if ( b != null )
      total += b.getStackSize();

    if ( c != null )
      total += c.getStackSize();

    return total;
  }
View Full Code Here

      if ( amt <= 0 )
        deleteVisualStack( l );
      else
      {
        IAEItemStack is = findVisualStack( l );
        is.setStackSize( amt );
      }
    }

    setScrollBar();
  }
View Full Code Here

    setScrollBar();
  }

  private void handleInput(IItemList<IAEItemStack> s, IAEItemStack l)
  {
    IAEItemStack a = s.findPrecise( l );

    if ( l.getStackSize() <= 0 )
    {
      if ( a != null )
        a.reset();
    }
    else
    {
      if ( a == null )
      {
        s.add( l.copy() );
        a = s.findPrecise( l );
      }

      if ( a != null )
        a.setStackSize( l.getStackSize() );
    }
  }
View Full Code Here

      {
        return o;
      }
    }

    IAEItemStack stack = l.copy();
    visual.add( stack );
    return stack;
  }
View Full Code Here

  private void deleteVisualStack(IAEItemStack l)
  {
    Iterator<IAEItemStack> i = visual.iterator();
    while (i.hasNext())
    {
      IAEItemStack o = i.next();
      if ( o.equals( l ) )
      {
        i.remove();
        return;
      }
    }
View Full Code Here

    int offY = 23;

    for (int z = viewStart; z < Math.min( viewEnd, visual.size() ); z++)
    {
      IAEItemStack refStack = visual.get( z );// repo.getReferenceItem( z );
      if ( refStack != null )
      {
        GL11.glPushMatrix();
        GL11.glScaled( 0.5, 0.5, 0.5 );

        IAEItemStack stored = storage.findPrecise( refStack );
        IAEItemStack activeStack = active.findPrecise( refStack );
        IAEItemStack pendingStack = pending.findPrecise( refStack );

        int lines = 0;

        if ( stored != null && stored.getStackSize() > 0 )
          lines++;
        if ( activeStack != null && activeStack.getStackSize() > 0 )
          lines++;
        if ( pendingStack != null && pendingStack.getStackSize() > 0 )
          lines++;

        int negY = ((lines - 1) * 5) / 2;
        int downY = 0;

        if ( stored != null && stored.getStackSize() > 0 )
        {
          String str = Long.toString( stored.getStackSize() );
          if ( stored.getStackSize() >= 10000 )
            str = Long.toString( stored.getStackSize() / 1000 ) + "k";
          if ( stored.getStackSize() >= 10000000 )
            str = Long.toString( stored.getStackSize() / 1000000 ) + "m";

          str = GuiText.Stored.getLocal() + ": " + str;
          int w = 4 + fontRendererObj.getStringWidth( str );
          fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
              + 6 - negY + downY) * 2, 4210752 );

          if ( tooltip == z - viewStart )
            lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );

          downY += 5;
        }

        if ( activeStack != null && activeStack.getStackSize() > 0 )
        {
          String str = Long.toString( activeStack.getStackSize() );
          if ( activeStack.getStackSize() >= 10000 )
            str = Long.toString( activeStack.getStackSize() / 1000 ) + "k";
          if ( activeStack.getStackSize() >= 10000000 )
            str = Long.toString( activeStack.getStackSize() / 1000000 ) + "m";

          str = GuiText.Crafting.getLocal() + ": " + str;
          int w = 4 + fontRendererObj.getStringWidth( str );
          fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
              + 6 - negY + downY) * 2, 4210752 );

          if ( tooltip == z - viewStart )
            lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );

          downY += 5;
        }

        if ( pendingStack != null && pendingStack.getStackSize() > 0 )
        {
          String str = Long.toString( pendingStack.getStackSize() );
          if ( pendingStack.getStackSize() >= 10000 )
            str = Long.toString( pendingStack.getStackSize() / 1000 ) + "k";
          if ( pendingStack.getStackSize() >= 10000000 )
            str = Long.toString( pendingStack.getStackSize() / 1000000 ) + "m";

          str = GuiText.Scheduled.getLocal() + ": " + str;
          int w = 4 + fontRendererObj.getStringWidth( str );
          fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
              + 6 - negY + downY) * 2, 4210752 );

          if ( tooltip == z - viewStart )
            lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );

        }

        GL11.glPopMatrix();
        int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
View Full Code Here

  {
    CellConfig cc = new CellConfig( o );
    for (ItemStack is : cc)
      if ( is != null )
      {
        IAEItemStack i = AEItemStack.create( is );
        i.setStackSize( Integer.MAX_VALUE );
        itemListCache.add( i );
      }
  }
View Full Code Here

TOP

Related Classes of appeng.api.storage.data.IAEItemStack

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.