I've added a enchantItem method in my container which now sends the command to open or close the gate and added the sendEnchantPacket under the actionPreformed sending the windowID and buttonID but im getting a NullPointerException. I not sure if I'm doing it correct but after looking at the enchantment GUI and Container class that's what I came up with.