Switch Item Slots in Minecraft using a Command Block

I want to be able to set the active hotbar slot with a command instead of the mouse wheel or keyboard shortcuts (1 through 9). I don't need to move items around in the hotbar, I just need to be able to set the active slot.

I have searched for this quite a while now and haven't found anything useful yet. Can somebody please tell me how I can achieve this for a given player?


Solution 1:

Actually you can't do it in Vanilla Minecraft. Selected slot is a NBT value. To change it you would use /entitydata, but the command doesn't work on players, only mobs and other entities. You can still use mods or Bukkit/Spigot Plugins, but vanilla commands won't work.