Mob spawning!

This commit is contained in:
Shoghi Cervantes Pueyo 2012-12-12 14:59:36 +01:00
parent a735ca460c
commit 51bb3faf39
5 changed files with 25 additions and 3 deletions

1
README
View File

@ -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

View File

@ -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));

View File

@ -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];

View File

@ -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);

View File

@ -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",