# HG changeset patch # User Jason Dufair # Date 1328032637 18000 # Node ID e207b5fdb092d8447231126a1d532f77a5dcb687 # Parent 9874586e98d18e71a76fc1853a8173ffc4d9c8a5 now working with protocol 23 (modulo a few intermittent errors) diff -r 9874586e98d1 -r e207b5fdb092 src/clojurecraft/core.clj --- a/src/clojurecraft/core.clj Tue Jan 31 11:39:50 2012 -0500 +++ b/src/clojurecraft/core.clj Tue Jan 31 12:57:17 2012 -0500 @@ -137,7 +137,7 @@ (println "connected and logged in") (println "queueing initial keepalive packet") - (.put outqueue [:keepalive {}]) + (.put outqueue [:keepalive {:keep-alive-id 0}]) (println "starting read handler") (.start (Thread. #(input-handler bot))) diff -r 9874586e98d1 -r e207b5fdb092 src/clojurecraft/in.clj --- a/src/clojurecraft/in.clj Tue Jan 31 11:39:50 2012 -0500 +++ b/src/clojurecraft/in.clj Tue Jan 31 12:57:17 2012 -0500 @@ -104,7 +104,8 @@ ; Reading Packets ------------------------------------------------------------------ (defn- read-packet-keepalive [bot conn] - {}) + (assoc {} + :keep-alive-id (-read-int conn))) (defn- read-packet-handshake [bot conn] (assoc {} @@ -115,7 +116,12 @@ :eid (-read-int conn) :unknown (-read-string-ucs2 conn) :seed (-read-long conn) - :dimension (-read-byte conn))) + :level-type (-read-string-ucs2 conn) + :server-mode (-read-int conn) + :dimension (-read-byte conn) + :difficulty (-read-byte conn) + :world-height (-read-byte conn) + :max-players (-read-byte conn))) (defn- read-packet-chat [bot conn] (let [payload (assoc {} @@ -645,6 +651,12 @@ :statisticid (-read-int conn) :amount (-read-byte conn))) +(defn- read-packet-playerlistitem [bot conn] + (assoc {} + :playername (-read-string-ucs2 conn) + :online (-read-bool conn) + :ping (-read-short conn))) + (defn- read-packet-disconnectkick [bot conn] (assoc {} :reason (-read-string-ucs2 conn))) @@ -702,6 +714,7 @@ :updatesign read-packet-updatesign :mapdata read-packet-mapdata :incrementstatistic read-packet-incrementstatistic + :playerlistitem read-packet-playerlistitem :disconnectkick read-packet-disconnectkick}) ; Reading Wrappers ----------------------------------------------------------------- @@ -732,6 +745,7 @@ (/ 1 0)) (let [payload (do ((packet-type packet-readers) bot conn))] (do + (println (str "--PACKET--> " packet-type)) (when (#{} packet-type) (println (str "--PACKET--> " packet-type))) [[packet-type payload] prev prev-prev])))))) diff -r 9874586e98d1 -r e207b5fdb092 src/clojurecraft/mappings.clj --- a/src/clojurecraft/mappings.clj Tue Jan 31 11:39:50 2012 -0500 +++ b/src/clojurecraft/mappings.clj Tue Jan 31 12:57:17 2012 -0500 @@ -59,6 +59,7 @@ 0x82 :updatesign 0x83 :mapdata 0xC8 :incrementstatistic + 0xC9 :playerlistitem 0xFF :disconnectkick }) (def packet-ids (invert packet-types)) diff -r 9874586e98d1 -r e207b5fdb092 src/clojurecraft/out.clj --- a/src/clojurecraft/out.clj Tue Jan 31 11:39:50 2012 -0500 +++ b/src/clojurecraft/out.clj Tue Jan 31 12:57:17 2012 -0500 @@ -44,8 +44,8 @@ ; Writing Packets ------------------------------------------------------------------ -(defn- write-packet-keepalive [conn _] - nil) +(defn- write-packet-keepalive [conn {keep-alive-id :keep-alive-id}] + (-write-int conn keep-alive-id)) (defn- write-packet-handshake [conn {username :username}] (-write-string-ucs2 conn username))