Package appeng.api.storage.data

Examples of appeng.api.storage.data.IAEItemStack


        for (IAEItemStack fuzz : inventory.getItemList().findFuzzy( g, FuzzyMode.IGNORE_ALL ))
        {
          fuzz = fuzz.copy();
          fuzz.setStackSize( g.getStackSize() );
          IAEItemStack ais = inventory.extractItems( fuzz, Actionable.SIMULATE, machineSrc );
          ItemStack is = ais == null ? null : ais.getItemStack();

          if ( is != null && is.stackSize == g.getStackSize() )
          {
            found = true;
            break;
          }
          else if ( is != null )
          {
            g = g.copy();
            g.decStackSize( is.stackSize );
          }
        }

        if ( !found )
          return false;
      }
      else
      {
        IAEItemStack ais = inventory.extractItems( g.copy(), Actionable.SIMULATE, machineSrc );
        ItemStack is = ais == null ? null : ais.getItemStack();

        if ( is == null || is.stackSize < g.getStackSize() )
          return false;
      }
    }
View Full Code Here


                      fuzz = fuzz.copy();
                      fuzz.setStackSize( input[x].getStackSize() );

                      if ( details.isValidItemForSlot( x, fuzz.getItemStack(), getWorld() ) )
                      {
                        IAEItemStack ais = inventory.extractItems( fuzz, Actionable.MODULATE, machineSrc );
                        ItemStack is = ais == null ? null : ais.getItemStack();

                        if ( is != null )
                        {
                          postChange( AEItemStack.create( is ), machineSrc );
                          ic.setInventorySlotContents( x, is );
                          found = true;
                          break;
                        }
                      }
                    }
                  }
                  else
                  {
                    IAEItemStack ais = inventory.extractItems( input[x].copy(), Actionable.MODULATE, machineSrc );
                    ItemStack is = ais == null ? null : ais.getItemStack();

                    if ( is != null )
                    {
                      postChange( input[x], machineSrc );
                      ic.setInventorySlotContents( x, is );
                      if ( is.stackSize == input[x].getStackSize() )
                      {
                        found = true;
                        continue;
                      }
                    }
                  }

                  if ( !found )
                    break;
                }

              }

              if ( !found )
              {
                // put stuff back..
                for (int x = 0; x < ic.getSizeInventory(); x++)
                {
                  ItemStack is = ic.getStackInSlot( x );
                  if ( is != null )
                    inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, machineSrc );
                }
                ic = null;
                break;
              }
            }

            if ( m.pushPattern( details, ic ) )
            {
              somethingChanged = true;
              remainingOperations--;

              for (IAEItemStack out : details.getCondensedOutputs())
              {
                postChange( out, machineSrc );
                waitingFor.add( out.copy() );
                postCraftingStatusChange( out.copy() );
              }

              if ( details.isCraftable() )
              {
                FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) getWorld() ),
                    details.getOutput( ic, getWorld() ), ic );

                for (int x = 0; x < ic.getSizeInventory(); x++)
                {
                  ItemStack output = Platform.getContainerItem( ic.getStackInSlot( x ) );
                  if ( output != null )
                  {
                    IAEItemStack cItem = AEItemStack.create( output );
                    postChange( cItem, machineSrc );
                    waitingFor.add( cItem );
                    postCraftingStatusChange( cItem );
                  }
                }
View Full Code Here

    return !tasks.isEmpty() || !waitingFor.isEmpty();
  }

  public IAEItemStack getItemStack(IAEItemStack what, CraftingItemList storage2)
  {
    IAEItemStack is = null;
    switch (storage2)
    {
    case STORAGE:
      is = inventory.getItemList().findPrecise( what );
      break;
    case ACTIVE:
      is = waitingFor.findPrecise( what );
      break;
    case PENDING:

      is = what.copy();
      is.setStackSize( 0 );

      for (Entry<ICraftingPatternDetails, TaskProgress> t : tasks.entrySet())
      {
        for (IAEItemStack ais : t.getKey().getCondensedOutputs())
        {
          if ( ais.equals( is ) )
            is.setStackSize( is.getStackSize() + ais.getStackSize() * t.getValue().value );
        }
      }

      break;
    default:
    case ALL:
      throw new RuntimeException( "Invalid Operation" );
    }

    if ( is != null )
      return is.copy();

    is = what.copy();
    is.setStackSize( 0 );
    return is;
  }
View Full Code Here

      {
        ais = ais.copy();
        ais.setStackSize( ais.getItemStack().getMaxStackSize() );
        while (true)
        {
          IAEItemStack g = inv.extractItems( ais.copy(), Actionable.MODULATE, cluster.getActionSource() );
          if ( g == null )
            break;

          WorldCoord wc = places.poll();
          places.add( wc );

          Platform.spawnDrops( worldObj, wc.x, wc.y, wc.z, Arrays.asList( g.getItemStack() ) );
        }

      }

      cluster.destroy();
View Full Code Here

    NBTTagList list = data.getTagList( "tasks", 10 );
    for (int x = 0; x < list.tagCount(); x++)
    {
      NBTTagCompound item = list.getCompoundTagAt( x );
      IAEItemStack pattern = AEItemStack.loadItemStackFromNBT( item );
      if ( pattern != null && pattern.getItem() instanceof ICraftingPatternItem )
      {
        ICraftingPatternItem cpi = (ICraftingPatternItem) pattern.getItem();
        ICraftingPatternDetails details = cpi.getPatternForItem( pattern.getItemStack(), getWorld() );
        if ( details != null )
        {
          TaskProgress tp = new TaskProgress();
          tp.value = item.getLong( "craftingProgress" );
          tasks.put( details, tp );
View Full Code Here

    if ( tag == null )
      return out;

    for (int x = 0; x < tag.tagCount(); x++)
    {
      IAEItemStack ais = AEItemStack.loadItemStackFromNBT( tag.getCompoundTagAt( x ) );
      if ( ais != null )
        out.add( ais );
    }

    return out;
View Full Code Here

    return node.isActive();
  }

  public boolean isMaking(IAEItemStack what)
  {
    IAEItemStack wat = waitingFor.findPrecise( what );
    return wat != null && wat.getStackSize() > 0;
  }
View Full Code Here

                  ItemStack newItemStack = r.matches( ic, pmp.worldObj ) ? r.getCraftingResult( ic ) : null;
                  ic.setInventorySlotContents( x, PatternItem );

                  if ( newItemStack == null || !Platform.isSameItemPrecise( newItemStack, is ) )
                  {
                    IAEItemStack in = AEItemStack.create( currentItem );
                    if ( in != null )
                    {
                      IAEItemStack out = realForFake == Actionable.SIMULATE ? null : Platform.poweredInsert( energy, storage, in,
                          cct.getSource() );
                      if ( out != null )
                        craftMatrix.setInventorySlotContents( x, out.getItemStack() );
                      else
                        craftMatrix.setInventorySlotContents( x, null );

                      currentItem = craftMatrix.getStackInSlot( x );
                    }
                  }
                }

                if ( PatternItem != null && currentItem == null )
                {
                  ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), storage, player.worldObj, r, is, ic,
                      PatternItem, x, all, realForFake, filter );

                  if ( whichItem == null )
                  {
                    for (int y = 0; y < recipe[x].length; y++)
                    {
                      IAEItemStack request = AEItemStack.create( recipe[x][y] );
                      if ( request != null )
                      {
                        if ( filter == null || filter.isListed( request ) )
                        {
                          request.setStackSize( 1 );
                          IAEItemStack out = Platform.poweredExtraction( energy, storage, request, cct.getSource() );
                          if ( out != null )
                          {
                            whichItem = out.getItemStack();
                            break;
                          }
                        }
                      }
                    }
View Full Code Here

      IMEInventory meInventory = getCell( sharedItemStack, null );
      if ( meInventory != null && !isEmpty( meInventory ) )
        return input;
    }

    IAEItemStack l = getCellItems().findPrecise( input );
    if ( l != null )
    {
      long remainingItemSlots = getRemainingItemCount();
      if ( remainingItemSlots < 0 )
        return input;

      if ( input.getStackSize() > remainingItemSlots )
      {
        IAEItemStack r = input.copy();
        r.setStackSize( r.getStackSize() - remainingItemSlots );
        if ( mode == Actionable.MODULATE )
        {
          l.setStackSize( l.getStackSize() + remainingItemSlots );
          updateItemCount( remainingItemSlots );
          saveChanges();
View Full Code Here

      return null;

    ItemStack sharedItem = request.getItemStack();
    int size = sharedItem.stackSize;

    IAEItemStack Results = null;

    IAEItemStack l = getCellItems().findPrecise( request );
    if ( l != null )
    {
      Results = l.copy();

      if ( l.getStackSize() <= size )
      {
        Results.setStackSize( l.getStackSize() );
        if ( mode == Actionable.MODULATE )
        {
          updateItemCount( -l.getStackSize() );
          l.setStackSize( 0 );
          saveChanges();
        }
      }
      else
      {
        Results.setStackSize( size );
        if ( mode == Actionable.MODULATE )
        {
          l.setStackSize( l.getStackSize() - size );
          updateItemCount( -size );
          saveChanges();
        }
      }
    }
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.