Package appeng.util.inv

Examples of appeng.util.inv.WrapperInvSlot


      ItemStack is = inv.server.getStackInSlot( slot );
      boolean hasItemInHand = player.inventory.getItemStack() != null;

      InventoryAdaptor playerHand = new AdaptorPlayerHand( player );

      WrapperInvSlot slotInv = new PatternInvSlot( inv.server );

      IInventory theSlot = slotInv.getWrapper( slot );
      InventoryAdaptor interfaceSlot = new AdaptorIInventory( theSlot );

      switch (action)
      {
      case PICKUP_OR_SET_DOWN:

        if ( hasItemInHand )
        {
          ItemStack inSlot = theSlot.getStackInSlot( 0 );
          if ( inSlot == null )
            player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) );
          else
          {
            inSlot = inSlot.copy();
            ItemStack inHand = player.inventory.getItemStack().copy();

            theSlot.setInventorySlotContents( 0, null );
            player.inventory.setItemStack( null );

            player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) );

            if ( player.inventory.getItemStack() == null )
              player.inventory.setItemStack( inSlot );
            else
            {
              player.inventory.setItemStack( inHand );
              theSlot.setInventorySlotContents( 0, inSlot );
            }
          }
        }
        else
        {
          IInventory mySlot = slotInv.getWrapper( slot );
          mySlot.setInventorySlotContents( 0, playerHand.addItems( mySlot.getStackInSlot( 0 ) ) );
        }

        break;
      case SPLIT_OR_PLACE_SINGLE:

        if ( hasItemInHand )
        {
          ItemStack extra = playerHand.removeItems( 1, null, null );
          if ( extra != null )
            extra = interfaceSlot.addItems( extra );
          if ( extra != null )
            playerHand.addItems( extra );
        }
        else if ( is != null )
        {
          ItemStack extra = interfaceSlot.removeItems( (is.stackSize + 1) / 2, null, null );
          if ( extra != null )
            extra = playerHand.addItems( extra );
          if ( extra != null )
            interfaceSlot.addItems( extra );
        }

        break;
      case SHIFT_CLICK:

        IInventory mySlot = slotInv.getWrapper( slot );
        InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
        mySlot.setInventorySlotContents( 0, playerInv.addItems( mySlot.getStackInSlot( 0 ) ) );

        break;
      case MOVE_REGION:
View Full Code Here

TOP

Related Classes of appeng.util.inv.WrapperInvSlot

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.