To fix the hotbar to inventory switching issue, I added a condition that you can’t move an item from the inventory to the hotbar if it’s value is 0.
And to fix the error that happens when you try to pick up an item but your existing items are in your hotbar, I made the ‘collect item’ function also check your hotbar if it can’t find the item in your inventory. You also have to force the game to redraw the hotbar if you collect an item to the hotbar, because otherwise it won’t update.
For the other two issues, the first is a game design issue (It’s up to you to decide what mechanism the player should use to craft!) and I’m not sure I understand what locking placing blocks means.
Here’s the fix, hope this helps!