code: private ItemStack handleHotbar(MalisisInventory inventory, MalisisSlot hoveredSlot, int num)
  	{
  		MalisisSlot hotbarSlot = getPlayerInventory().getSlot(num);
  
  		// slot from player's inventory, swap itemStacks
  		if (inventory == getPlayerInventory() || hoveredSlot.getItemStack().isEmpty())
  		{
  			if (hoveredSlot.isState(PLAYER_INSERT))
  			{
  				ItemStack dest = hotbarSlot.extract(ItemUtils.FULL_STACK);
  				ItemStack src = hoveredSlot.extract(ItemUtils.FULL_STACK);
  
  				dest = hoveredSlot.insert(dest);
  				//couldn't fit all into the slot, put back what's left in hotbar
  				if (!dest.isEmpty())
  				{
  					hotbarSlot.insert(dest);
  					//src should be empty but better safe than sorry
  					inventory.transferInto(src);
  				}
  				else
  					src = hotbarSlot.insert(src);
  			}
  		}
  		// merge itemStack in slot into hotbar. If already holding an itemStack, move elsewhere inside player inventory
  		else
  		{
  			if (hoveredSlot.isState(PLAYER_EXTRACT))
  			{
  				ItemStack dest = hoveredSlot.extract(ItemUtils.FULL_STACK);
  				ItemStack left = hotbarSlot.insert(dest, ItemUtils.FULL_STACK, true);
  				getPlayerInventory().transferInto(left, false);
  			}
  		}
  
  		return hotbarSlot.getItemStack();
  	}
docs: Handles player pressing 1-9 key while hovering a slot.
  
  @param hoveredSlot hoveredSlot
  @param num the num
  @return the item stack