public ItemStack handleAction(ActionType action, int inventoryId, int slotNumber, int code)
	{
		MalisisInventory inventory = getInventory(inventoryId);
		if (inventory == null)
		{
			MalisisCore.log.error("[MalisisInventoryContainer] Tried to handle an action for a wrong inventory (" + inventoryId + ").");
			return null;
		}
		MalisisSlot slot = inventory.getSlot(slotNumber);
		if (slot == null)
		{
			MalisisCore.log.error("[MalisisInventoryContainer] Tried to handle an action for a wrong slotNumber (" + slotNumber + ").");
			return null;
		}

		if (slot.isState(FROZEN))
			return pickedItemStack;

		//first check if current slot is current providing inventory (for Items providing inventory)
		//TODO : freeze the slot at inventory creation
		if (slot.getItemStack().getItem() instanceof IInventoryProvider && slot.getItemStack().getTagCompound() != null)
		{
			NBTTagCompound nbt = slot.getItemStack().getTagCompound();
			if (nbt.hasKey("inventoryId"))
			{
				if (nbt.getInteger("inventoryId") == 0) //it is main inventory
				{
					owner.closeScreen();
					nbt.removeTag("inventoryId");
					return null;
				}
				else //removed the stack with inventory, it's not opened anymore
					nbt.removeTag("inventoryId");
			}
		}

		// player pressed 1-9 key while hovering a slot
		if (action == HOTBAR && code >= 0 && code < 9)
			return handleHotbar(inventory, slot, code);

		// player pressed keyBindDrop key while hovering a slot
		if (action == DROP_SLOT_STACK || action == DROP_SLOT_ONE)
			return handleDropSlot(slot, action == DROP_SLOT_STACK);

		// player started/ended/reset/is currently dragging
		if (action.isDragAction())
			return handleDrag(action, slot);

		// from this point, any action should stop the dragging
		resetDrag();

		// player clicked outside the GUI with an item picked up
		if (action == DROP_ONE || action == DROP_STACK)
			return handleDropPickedStack(action == DROP_STACK);

		//player middle click on a slot
		if (action == PICKBLOCK && owner.capabilities.isCreativeMode)
			return handlePickBlock(slot);

		//normal left/right click
		if (action == LEFT_CLICK || action == RIGHT_CLICK)
			return handleNormalClick(slot, action == LEFT_CLICK);

		if (action == SHIFT_LEFT_CLICK)
		{
			// we need to store last shift clicked item for double click because at the time of the second click, slot may be empty and we
			// wouldn't know what itemStack to move
			lastShiftClicked = slot.getItemStack();
			ItemStack itemStack = handleShiftClick(inventory, slot);
			if (itemStack.isEmpty())
				lastShiftClicked = ItemStack.EMPTY;
			return itemStack;
		}

		if (action == DOUBLE_LEFT_CLICK || action == DOUBLE_SHIFT_LEFT_CLICK)
			return handleDoubleClick(inventory, slot, action == DOUBLE_SHIFT_LEFT_CLICK);

		return null;
	}
public ItemStack handleAction ( ActionType action , int inventoryId , int slotNumber , int code ) { MalisisInventory inventory = getInventory ( inventoryId ) ; if ( inventory == null ) { MalisisCore . log . error ( "[MalisisInventoryContainer] Tried to handle an action for a wrong inventory (" + inventoryId + ")." ) ; return null ; } MalisisSlot slot = inventory . getSlot ( slotNumber ) ; if ( slot == null ) { MalisisCore . log . error ( "[MalisisInventoryContainer] Tried to handle an action for a wrong slotNumber (" + slotNumber + ")." ) ; return null ; } if ( slot . isState ( FROZEN ) ) return pickedItemStack ; if ( slot . getItemStack ( ) . getItem ( ) instanceof IInventoryProvider && slot . getItemStack ( ) . getTagCompound ( ) != null ) { NBTTagCompound nbt = slot . getItemStack ( ) . getTagCompound ( ) ; if ( nbt . hasKey ( "inventoryId" ) ) { if ( nbt . getInteger ( "inventoryId" ) == 0 ) { owner . closeScreen ( ) ; nbt . removeTag ( "inventoryId" ) ; return null ; } else nbt . removeTag ( "inventoryId" ) ; } } if ( action == HOTBAR && code >= 0 && code < 9 ) return handleHotbar ( inventory , slot , code ) ; if ( action == DROP_SLOT_STACK || action == DROP_SLOT_ONE ) return handleDropSlot ( slot , action == DROP_SLOT_STACK ) ; if ( action . isDragAction ( ) ) return handleDrag ( action , slot ) ; resetDrag ( ) ; if ( action == DROP_ONE || action == DROP_STACK ) return handleDropPickedStack ( action == DROP_STACK ) ; if ( action == PICKBLOCK && owner . capabilities . isCreativeMode ) return handlePickBlock ( slot ) ; if ( action == LEFT_CLICK || action == RIGHT_CLICK ) return handleNormalClick ( slot , action == LEFT_CLICK ) ; if ( action == SHIFT_LEFT_CLICK ) { lastShiftClicked = slot . getItemStack ( ) ; ItemStack itemStack = handleShiftClick ( inventory , slot ) ; if ( itemStack . isEmpty ( ) ) lastShiftClicked = ItemStack . EMPTY ; return itemStack ; } if ( action == DOUBLE_LEFT_CLICK || action == DOUBLE_SHIFT_LEFT_CLICK ) return handleDoubleClick ( inventory , slot , action == DOUBLE_SHIFT_LEFT_CLICK ) ; return null ; }
Handles the action for this {@link MalisisInventoryContainer}. See {@link ActionType} for possible actions.

@param action the action
@param inventoryId the inventory id
@param slotNumber the slot number
@param code the code
@return itemStack resulting of the actions. Should be used to check client/server coherence.