public boolean handlePacket(NetworkManager networkHandler) throws IOException {
        networkHandler.in.flip();
        byte packetId = networkHandler.in.get(0);
        if (packetId < 0 || packetId > PacketType.packets.length - 1) {
            throw new IOException("Unknown packet ID received: " + packetId);
        }

        PacketType packetType = PacketType.packets[packetId];
        if (networkHandler.in.remaining() < packetType.length + 1) {
            // No more packets left to read
            networkHandler.in.compact();
            return false;
        }
        networkHandler.in.get();
        Object[] packetParams = new Object[packetType.params.length];

        for (int i = 0; i < packetParams.length; ++i) {
            packetParams[i] = networkHandler.readObject(packetType.params[i]);
        }

        if (networkHandler.isConnected()) {
            if (packetType.opcode > PacketType.UPDATE_PLAYER_TYPE.opcode) {
                handleExtendedPacket(networkHandler, packetType, packetParams);
            } else {
                handleStandardPacket(networkHandler, packetType, packetParams);
            }
        }

        if (networkHandler.isConnected()) {
            networkHandler.in.compact();
            return true;
        } else {
            // We've been disconnected!
            return false;
        }
    }