# HG changeset patch # User Steve Losh # Date 1311308871 14400 # Node ID 1ec79708efe259b7103944fae42d97034dbdfc44 # Parent 32c0894fccce62ab5b7a2aac1144f5d68a007b10 Entity packets. diff -r 32c0894fccce -r 1ec79708efe2 src/clojurecraft/core.clj --- a/src/clojurecraft/core.clj Fri Jul 22 00:11:47 2011 -0400 +++ b/src/clojurecraft/core.clj Fri Jul 22 00:27:51 2011 -0400 @@ -120,11 +120,12 @@ ; Scratch -------------------------------------------------------------------------- (def minecraft-local {:name "localhost" :port 25565}) -(def bot (connect minecraft-local nil)) +;(def bot (connect minecraft-local nil)) ;(act/move bot -2 0 0) ;(pprint @(:packet-counts-in bot)) ;(pprint @(:packet-counts-out bot)) ;(pprint (:player bot)) +;(pprint (:world bot)) ;(println (:loc @(:player bot))) ;(disconnect bot) diff -r 32c0894fccce -r 1ec79708efe2 src/clojurecraft/in.clj --- a/src/clojurecraft/in.clj Fri Jul 22 00:11:47 2011 -0400 +++ b/src/clojurecraft/in.clj Fri Jul 22 00:27:51 2011 -0400 @@ -2,7 +2,7 @@ (:use [clojurecraft.util]) (:use [clojurecraft.mappings]) (:require [clojurecraft.data]) - (:import [clojurecraft.data Location]) + (:import [clojurecraft.data Location Entity]) (:import (java.util.zip Inflater))) ; Bytes ---------------------------------------------------------------------------- @@ -289,8 +289,15 @@ :eid (-read-int conn))) (defn- read-packet-entity [bot conn] - (assoc {} - :eid (-read-int conn))) + (let [payload (assoc {} + :eid (-read-int conn))] + (dosync + (let [eid (:eid payload) + entities (:entities (:world bot)) + entity (@entities eid)] + (when-not entity + (alter entities assoc eid (Entity. eid nil false))))) + payload)) (defn- read-packet-entityrelativemove [bot conn] (assoc {}