ff65b7a331b2
Moar.
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Tue, 21 Jun 2011 21:18:32 -0400 |
parents | 2ace53af7b31 |
children | 1193dce21ecd |
branches/tags | (none) |
files | src/clojurecraft/core.clj |
Changes
--- a/src/clojurecraft/core.clj Tue Jun 21 21:12:36 2011 -0400 +++ b/src/clojurecraft/core.clj Tue Jun 21 21:18:32 2011 -0400 @@ -16,6 +16,8 @@ 0x07 :useentity 0x08 :updatehealth 0x09 :respawn + 0x0A :player + 0x0B :playerposition }) (def packet-ids (apply assoc {} (mapcat reverse packet-types))) @@ -55,6 +57,11 @@ (doto (:out @conn) (.writeLong (int i)))) +(defn -write-double [conn i] + (println (str "-> DOUBLE: " i)) + (doto (:out @conn) + (.writeDouble (int i)))) + (defn -write-string16 [conn s] (-write-short conn (count s)) (println (str "-> STRING: " s)) @@ -94,6 +101,21 @@ (-write-bool conn world)) +(defn write-packet-player [conn {onground :onground}] + (-write-byte conn (:player packet-ids)) + + (-write-bool conn onground)) + +(defn write-packet-playerposition [conn {x :x y :y stance :stance z :z onground :onground}] + (-write-byte conn (:playerposition packet-ids)) + + (-write-double conn x) + (-write-double conn y) + (-write-double conn stance) + (-write-double conn z) + (-write-bool conn onground) + ) + ; Writing Wrappers ----------------------------------------------------------------- (defn flushc [conn] @@ -101,11 +123,13 @@ (defn write-packet [conn packet-type payload] (cond - (= packet-type :keepalive) (write-packet-handshake conn payload) - (= packet-type :handshake) (write-packet-handshake conn payload) - (= packet-type :login) (write-packet-login conn payload) - (= packet-type :chat) (write-packet-chat conn payload) - (= packet-type :respawn) (write-packet-respawn conn payload) + (= packet-type :keepalive) (write-packet-handshake conn payload) + (= packet-type :handshake) (write-packet-handshake conn payload) + (= packet-type :login) (write-packet-login conn payload) + (= packet-type :chat) (write-packet-chat conn payload) + (= packet-type :respawn) (write-packet-respawn conn payload) + (= packet-type :player) (write-packet-player conn payload) + (= packet-type :playerposition) (write-packet-playerposition conn payload) ) (flushc conn))