      :login 0x01
      :handshake 0x02
      :chat 0x03
+     :timeupdate 0x04
 })
 (def packet-types (apply assoc {} (mapcat reverse packet-ids)))
 


; Reading Packets ------------------------------------------------------------------
(defn read-packet-keepalive [conn]
      (println "OMG got a keepalive")
      nil)

(defn read-packet-handshake [conn]
      (println "OMG got a handshake")
      (-> {}
          (assoc :hash (red-string16 conn))))

(defn read-packet-login [conn]
      (println "OMG got a login")
      (-> {}
          (assoc :eid (red-int conn))
          (assoc :unknown (red-string16 conn))
          (assoc :seed (red-long conn))
          (assoc :dimension (red-byte conn))))

(defn read-packet [conn packet-id]
      (let [packet-id (int packet-id)

    (write-packet conn :handshake {:username "timmy"})

    ; Get handshake
    (let [packet-id (-read-byte conn)]
      (read-packet conn packet-id))

    ; Send login
    (write-packet conn :login {:version 13 :username "timmy"})

    ; Get login
    (let [packet-id (-read-byte conn)]
      (read-packet conn packet-id)))

(defn conn-handler [conn]
