packets.lua: Added packet mode detection