# HG changeset patch # User Steve Losh # Date 1308872154 14400 # Node ID 6b4574bb3ec67841ed8b28d5444a508f8c2ab2fa # Parent a749c950b00d6d9d986b08ac37eac431a8a17e94 Moar. diff -r a749c950b00d -r 6b4574bb3ec6 src/clojurecraft/core.clj --- a/src/clojurecraft/core.clj Thu Jun 23 19:29:50 2011 -0400 +++ b/src/clojurecraft/core.clj Thu Jun 23 19:35:54 2011 -0400 @@ -120,6 +120,10 @@ (doto (:out @conn) (.writeFloat (int i)))) +(defn -write-string8 [conn s] + ; TODO: Implement this. + nil) + (defn -write-string16 [conn s] (-write-short conn (count s)) (println (str "-> STRING: " s)) @@ -332,6 +336,15 @@ (-write-byte conn reason)) +(defn write-packet-openwindow [conn {windowid :windowid inventorytype :inventorytype windowtitle :windowtitle numberofslots :numberofslots}] + (-write-byte conn (:openwindow packet-ids)) + + (-write-byte conn windowid) + (-write-byte conn inventorytype) + (-write-string8 conn windowtitle) + (-write-byte conn numberofslots) +) + ; Writing Wrappers ----------------------------------------------------------------- (defn flushc [conn] @@ -365,6 +378,7 @@ :explosion (write-packet-explosion conn payload) :soundeffect (write-packet-soundeffect conn payload) :newinvalidstate (write-packet-newinvalidstate conn payload) + :openwindow (write-packet-openwindow conn payload) ) (flushc conn)) @@ -407,6 +421,10 @@ (let [i (.readFloat (:in @conn))] i)) +(defn -read-string8 [conn] + ; TODO: Implement this. + nil) + (defn -read-string16 [conn] (let [str-len (.readShort (:in @conn)) s (apply str (repeatedly str-len #(.readChar (:in @conn))))] @@ -719,6 +737,21 @@ (assoc {} :reason (-read-byte conn))) +(defn read-packet-thunderbolt [conn] + (assoc {} + :eid (-read-int conn) + :unknown (-read-bool conn) + :x (-read-int conn) + :y (-read-int conn) + :z (-read-int conn))) + +(defn read-packet-openwindow [conn] + (assoc {} + :windowid (-read-byte conn) + :inventorytype (-read-byte conn) + :windowtitle (-read-string8 conn) + :numberofslots (-read-byte conn))) + ; Reading Wrappers ----------------------------------------------------------------- (defn read-packet [conn packet-id] @@ -769,6 +802,8 @@ :explosion (read-packet-explosion conn) :soundeffect (read-packet-soundeffect conn) :newinvalidstate (read-packet-newinvalidstate conn) + :thunderbolt (read-packet-thunderbolt conn) + :openwindow (read-packet-openwindow conn) :else (str "UNKNOWN PACKET TYPE: " packet-id) ))