From 51bb3faf39a0dde53e90e54e21382d64ed265492 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Wed, 12 Dec 2012 14:59:36 +0100 Subject: [PATCH] Mob spawning! --- README | 1 + classes/CustomPacketHandler.class.php | 21 +++++++++++++++++++++ classes/Session.class.php | 4 +--- pstruct/5.php | 1 + pstruct/dataName.php | 1 + 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README b/README index bd7b3517f..93a64de4d 100644 --- a/README +++ b/README @@ -44,6 +44,7 @@ Current features of the server: - Extensible API! - Online list broadcast - Configurable day/night cycle + - Mob spawning! - Health and position saving - server.properties configuration file - Whitelist and IP Ban files diff --git a/classes/CustomPacketHandler.class.php b/classes/CustomPacketHandler.class.php index 6612cdd58..94ac7c2f0 100644 --- a/classes/CustomPacketHandler.class.php +++ b/classes/CustomPacketHandler.class.php @@ -184,6 +184,27 @@ class CustomPacketHandler{ $this->raw .= Utils::writeFloat($this->data["z"]); } break; + case MC_ADD_MOB: + if($this->c === false){ + $this->data["int"] = Utils::readInt($this->get(4)); + $this->data["type"] = Utils::readInt($this->get(4)); + $this->data["x"] = Utils::readFloat($this->get(4)); + $this->data["y"] = Utils::readFloat($this->get(4)); + $this->data["z"] = Utils::readFloat($this->get(4)); + $this->data["metadata"] = Utils::readMetadata($this->get(true)); + }else{ + $this->raw .= Utils::writeInt($this->data["eid"]); + $this->raw .= Utils::writeInt($this->data["type"]); + $this->raw .= Utils::writeFloat($this->data["x"]); + $this->raw .= Utils::writeFloat($this->data["y"]); + $this->raw .= Utils::writeFloat($this->data["z"]); + $this->raw .= Utils::writeMetadata(array( + 1 => array("type" => 1, "value" => 300), + 16 => array("type" => 0, "value" => 0), + 17 => array("type" => 6, "value" => array(0, 0, 0)), + )); + } + break; case MC_ADD_PLAYER: if($this->c === false){ $this->data["clientID"] = Utils::readLong($this->get(8)); diff --git a/classes/Session.class.php b/classes/Session.class.php index a6a2a10ef..68a495fa2 100644 --- a/classes/Session.class.php +++ b/classes/Session.class.php @@ -351,14 +351,12 @@ class Session{ $this->counter[0], 0x00, array( - "id" => MC_ADD_ITEM_ENTITY, + "id" => MC_ADD_MOB, "eid" => $entity->eid, "type" => $entity->type, "x" => $entity->position["x"], "y" => $entity->position["y"], "z" => $entity->position["z"], - "block" => 10, - "meta" => 0, ), )); ++$this->counter[0]; diff --git a/pstruct/5.php b/pstruct/5.php index f154db017..18677d77a 100644 --- a/pstruct/5.php +++ b/pstruct/5.php @@ -44,6 +44,7 @@ define("MC_CHAT", 0x85); define("MC_SET_TIME", 0x86); define("MC_START_GAME", 0x87); +define("MC_ADD_MOB", 0x88); define("MC_ADD_PLAYER", 0x89); define("MC_ADD_ENTITY", 0x8c); diff --git a/pstruct/dataName.php b/pstruct/dataName.php index 32c57795f..078b0ad80 100644 --- a/pstruct/dataName.php +++ b/pstruct/dataName.php @@ -44,6 +44,7 @@ $dataName = array( MC_SET_TIME => "SetTime", MC_START_GAME => "StartGame", + MC_ADD_MOB => "AddMob", MC_ADD_PLAYER => "AddPlayer", MC_ADD_ENTITY => "AddEntity",