Package appeng.core.sync.packets

Examples of appeng.core.sync.packets.PacketInventoryAction


  {
    if ( Platform.isServer() )
    {
      try
      {
        NetworkHandler.instance.sendTo( new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.create( p.inventory.getItemStack() ) ),
            p );
      }
      catch (IOException e)
      {
        AELog.error( e );
View Full Code Here


        InventoryAction direction = wheel > 0 ? InventoryAction.ROLL_DOWN : InventoryAction.ROLL_UP;
        int times = Math.abs( wheel );
        final int inventorySize = this.getInventorySlots().size();
        for (int h = 0; h < times; h++)
        {
          PacketInventoryAction p = new PacketInventoryAction( direction, inventorySize, 0 );
          NetworkHandler.instance.sendToServer( p );
        }
      }
    }
  }
View Full Code Here

      final InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;

      if ( drag_click.size() > 1 )
        return;

      PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
      NetworkHandler.instance.sendToServer( p );

      return;
    }

    if ( slot instanceof SlotPatternTerm )
    {
      if ( key == 6 )
        return; // prevent weird double clicks..

      try
      {
        NetworkHandler.instance.sendToServer( ((SlotPatternTerm) slot).getRequest( key == 1 ) );
      }
      catch (IOException e)
      {
        AELog.error( e );
      }
    }
    else if ( slot instanceof SlotCraftingTerm )
    {
      if ( key == 6 )
        return; // prevent weird double clicks..

      InventoryAction action = null;
      if ( key == 1 )
        action = InventoryAction.CRAFT_SHIFT;
      else
        action = ctrlDown == 1 ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;

      PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
      NetworkHandler.instance.sendToServer( p );

      return;
    }

    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;
          }
        }
        break;

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

      if ( action != null )
      {
        ((AEBaseContainer) inventorySlots).setTargetStack( stack );
        PacketInventoryAction p = new PacketInventoryAction( action, this.getInventorySlots().size(), 0 );
        NetworkHandler.instance.sendToServer( p );
      }

      return;
    }
View Full Code Here

      drag_click.add( slot );
      if ( drag_click.size() > 1 )
      {
        for (Slot dr : drag_click)
        {
          PacketInventoryAction p = new PacketInventoryAction( c == 0 ? InventoryAction.PICKUP_OR_SET_DOWN : InventoryAction.PLACE_SINGLE,
              dr.slotNumber, 0 );
          NetworkHandler.instance.sendToServer( p );
        }
      }
    }
View Full Code Here

          s = (Slot) j;
      }

      if ( s != null )
      {
        PacketInventoryAction p;
        p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 );
        NetworkHandler.instance.sendToServer( p );
      }
    }
  }
View Full Code Here

TOP

Related Classes of appeng.core.sync.packets.PacketInventoryAction

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.