I am trying to find a way to move items from the player into an opened chest, kind of like a death chest mod but completely client side, so that it will work on servers. What I tried using is this (inside of a keybind):
EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
player.openContainer.transferStackInSlot(player, 1);
This transfers the items in slot one of the chest into the player's inventory when I press the bound key and have a chest open, but once you try to pick up the transferred items, they revert to where they were before. I tried adding this, to see if it would help:
player.openContainer.detectAndSendChanges();
player.inventoryContainer.detectAndSendChanges();
But those didn't help either. What should I do to get this code to work, or is there another method that will work? Thanks in advance!