Package appeng.api.storage.data

Examples of appeng.api.storage.data.IAEItemStack


  }

  @Override
  public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
  {
    IAEItemStack local = itemListCache.findPrecise( input );
    if ( local == null )
      return input;

    return null;
  }
View Full Code Here


  }

  @Override
  public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
  {
    IAEItemStack local = itemListCache.findPrecise( request );
    if ( local == null )
      return null;

    return request.copy();
  }
View Full Code Here

  private boolean isWorking = false;

  @Override
  public boolean canInsert(ItemStack stack)
  {
    IAEItemStack out = destination.injectItems( AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, null );
    if ( out == null )
      return true;
    return out.getStackSize() != stack.stackSize;
    // ItemStack after = adaptor.simulateAdd( stack );
    // if ( after == null )
    // return true;
    // return after.stackSize != stack.stackSize;
  }
View Full Code Here

    // return after.stackSize != stack.stackSize;
  }

  private void updatePlan(int slot)
  {
    IAEItemStack req = config.getAEStackInSlot( slot );
    if ( req != null && req.getStackSize() <= 0 )
    {
      config.setInventorySlotContents( slot, null );
      req = null;
    }

    ItemStack Stored = storage.getStackInSlot( slot );

    if ( req == null && Stored != null )
    {
      IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
      requireWork[slot] = work.setStackSize( -work.getStackSize() );
      return;
    }
    else if ( req != null )
    {
      if ( Stored == null ) // need to add stuff!
      {
        requireWork[slot] = req.copy();
        return;
      }
      else if ( req.isSameType( Stored ) ) // same type ( qty different? )!
      {
        if ( req.getStackSize() != Stored.stackSize )
        {
          requireWork[slot] = req.copy();
          requireWork[slot].setStackSize( req.getStackSize() - Stored.stackSize );
          return;
        }
      }
      else // Stored != null; dispose!
      {
        IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
        requireWork[slot] = work.setStackSize( -work.getStackSize() );
        return;
      }
    }

    // else
View Full Code Here

        {
          changed = true;
          throw new GridAccessException();
        }

        IAEItemStack acquired = Platform.poweredExtraction( src, destination, itemStack, mySrc );
        if ( acquired != null )
        {
          changed = true;
          ItemStack issue = adaptor.addItems( acquired.getItemStack() );
          if ( issue != null )
            throw new RuntimeException( "bad attempt at managing inventory. ( addItems )" );
        }
        else
          changed = handleCrafting( x, adaptor, itemStack ) || changed;
      }
      else if ( itemStack.getStackSize() < 0 )
      {
        IAEItemStack toStore = itemStack.copy();
        toStore.setStackSize( -toStore.getStackSize() );

        long diff = toStore.getStackSize();

        // make sure strange things didn't happen...
        ItemStack canExtract = adaptor.simulateRemove( (int) diff, toStore.getItemStack(), null );
        if ( canExtract == null || canExtract.stackSize != diff )
        {
          changed = true;
          throw new GridAccessException();
        }

        toStore = Platform.poweredInsert( src, destination, toStore, mySrc );

        if ( toStore != null )
          diff -= toStore.getStackSize();

        if ( diff != 0 )
        {
          // extract items!
          changed = true;
View Full Code Here

      if ( mode == Actionable.SIMULATE )
        return AEItemStack.create( adaptor.simulateAdd( acquired.getItemStack() ) );
      else
      {
        IAEItemStack is = AEItemStack.create( adaptor.addItems( acquired.getItemStack() ) );
        updatePlan( slot );
        return is;
      }
    }
View Full Code Here

  protected void mouseWheelEvent(int x, int y, int wheel)
  {
    Slot slot = getSlot( x, y );
    if ( slot instanceof SlotME )
    {
      IAEItemStack item = ((SlotME) slot).getAEStack();
      if ( item != null )
      {
        ((AEBaseContainer) inventorySlots).setTargetStack( item );
        InventoryAction direction = wheel > 0 ? InventoryAction.ROLL_DOWN : InventoryAction.ROLL_UP;
        int times = Math.abs( wheel );
View Full Code Here

    if ( Keyboard.isKeyDown( Keyboard.KEY_SPACE ) )
    {
      if ( enableSpaceClicking() )
      {
        IAEItemStack stack = null;
        if ( slot instanceof SlotME )
          stack = ((SlotME) slot).getAEStack();

        int slotNum = this.getInventorySlots().size();

        if ( !(slot instanceof SlotME) && slot != null )
          slotNum = slot.slotNumber;

        ((AEBaseContainer) inventorySlots).setTargetStack( stack );
        PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, 0 );
        NetworkHandler.instance.sendToServer( p );
        return;
      }
    }

    if ( slot instanceof SlotDisconnected )
    {
      InventoryAction action = null;

      switch (key)
      {
      case 0: // pickup / set-down.
        action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
        break;
      case 1:
        action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
        break;

      case 3: // creative dupe:

        if ( player.capabilities.isCreativeMode )
        {
          action = InventoryAction.CREATIVE_DUPLICATE;
        }

        break;

      default:
      case 4: // drop item:
      case 6:
      }

      if ( action != null )
      {
        PacketInventoryAction p = new PacketInventoryAction( action, slot.getSlotIndex(), ((SlotDisconnected) slot).mySlot.id );
        NetworkHandler.instance.sendToServer( p );
      }

      return;
    }

    if ( slot instanceof SlotME )
    {
      InventoryAction action = null;
      IAEItemStack stack = null;

      switch (key)
      {
      case 0: // pickup / set-down.
        action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
        stack = ((SlotME) slot).getAEStack();

        if ( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null )
          action = InventoryAction.AUTO_CRAFT;

        break;
      case 1:
        action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
        stack = ((SlotME) slot).getAEStack();
        break;

      case 3: // creative dupe:

        stack = ((SlotME) slot).getAEStack();
        if ( stack != null && stack.isCraftable() )
          action = InventoryAction.AUTO_CRAFT;

        else if ( player.capabilities.isCreativeMode )
        {
          IAEItemStack slotItem = ((SlotME) slot).getAEStack();
          if ( slotItem != null )
          {
            action = InventoryAction.CREATIVE_DUPLICATE;
          }
        }
View Full Code Here

      Slot s = getSlot( mouseX, mouseY );
      if ( s instanceof SlotME )
      {
        int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;

        IAEItemStack myStack = null;

        try
        {
          SlotME theSlotField = (SlotME) s;
          myStack = theSlotField.getAEStack();
        }
        catch (Throwable ignore)
        {
        }

        if ( myStack != null )
        {
          if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
            currentToolTip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );

          if ( myStack.getCountRequestable() > 0 )
            currentToolTip.add( "\u00a77Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
        }
        else if ( stack.stackSize > BigNumber || (stack.stackSize > 1 && stack.isItemDamaged()) )
        {
          currentToolTip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
        }
View Full Code Here

    Slot s = getSlot( x, y );
    if ( s instanceof SlotME && stack != null )
    {
      int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;

      IAEItemStack myStack = null;

      try
      {
        SlotME theSlotField = (SlotME) s;
        myStack = theSlotField.getAEStack();
      }
      catch (Throwable ignore)
      {
      }

      if ( myStack != null )
      {
        List currentToolTip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );

        if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
          currentToolTip.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );

        if ( myStack.getCountRequestable() > 0 )
          currentToolTip.add( "Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );

        drawTooltip( x, y, 0, join( currentToolTip, "\n" ) );
      }
      else if ( stack.stackSize > BigNumber )
      {
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.