Multiple Paintings

This commit is contained in:
Shoghi Cervantes Pueyo 2013-02-06 17:04:19 +01:00
parent d2dcf4f43a
commit e288a8a880
3 changed files with 37 additions and 4 deletions

View File

@ -331,7 +331,7 @@ class PocketMinecraftServer{
"yaw" => $entity["Rotation"][0],
"pitch" => $entity["Rotation"][1],
));
}elseif($entity["id"] === 83){ //Painting
}elseif($entity["id"] === OBJECT_PAINTING){ //Painting
$e = $this->api->entity->add(ENTITY_OBJECT, $entity["id"], $entity);
$e->setPosition($entity["Pos"][0], $entity["Pos"][1], $entity["Pos"][2], $entity["Rotation"][0], $entity["Rotation"][1]);
$e->setHealth($entity["Health"]);
@ -363,7 +363,7 @@ class PocketMinecraftServer{
if(count($this->entities) > 0){
$entities = array();
foreach($this->entities as $entity){
if($entity->class === ENTITY_MOB or $entity->class === ENTITY_OBJECT){
if($entity->class === ENTITY_MOB){
$entities[] = array(
"id" => $entity->type,
"Color" => @$entity->data["Color"],
@ -379,6 +379,24 @@ class PocketMinecraftServer{
1 => $entity->pitch,
),
);
}elseif($entity->class === ENTITY_OBJECT){
$entities[] = array(
"id" => $entity->type,
"TileX" => $entity->x,
"TileX" => $entity->y,
"TileX" => $entity->z,
"Health" => $entity->health,
"Motive" => $entity->data["Motive"],
"Pos" => array(
0 => $entity->x,
1 => $entity->y,
2 => $entity->z,
),
"Rotation" => array(
0 => $entity->yaw,
1 => $entity->pitch,
),
);
}elseif($entity->class === ENTITY_ITEM){
$entities[] = array(
"id" => 64,

View File

@ -40,12 +40,22 @@ class PaintingItem extends Item{
5 => 2,
);
$motives = array(
"Kebab",
"Aztec",
"Alban",
"Aztec2",
"Bomb",
"Plant",
"Wasteland",
);
$data = array(
"x" => $target->x,
"y" => $target->y,
"z" => $target->z,
"yaw" => $faces[$face] * 90,
"Motive" => $motives[mt_rand(0, count($motives) - 1)],
);
$server = ServerAPI::request();
$e = $server->api->entity->add(ENTITY_OBJECT, OBJECT_PAINTING, $data);

View File

@ -97,7 +97,6 @@ class Entity extends stdClass{
$this->name = "";
$this->tickCounter = 0;
$this->server->query("INSERT OR REPLACE INTO entities (EID, type, class, health) VALUES (".$this->eid.", ".$this->type.", ".$this->class.", ".$this->health.");");
$this->server->schedule(5, array($this, "update"), array(), true);
$this->x = isset($this->data["x"]) ? $this->data["x"]:0;
$this->y = isset($this->data["y"]) ? $this->data["y"]:0;
$this->z = isset($this->data["z"]) ? $this->data["z"]:0;
@ -112,17 +111,23 @@ class Entity extends stdClass{
case ENTITY_PLAYER:
$this->player = $this->data["player"];
$this->setHealth($this->health, "generic");
$this->server->schedule(5, array($this, "update"), array(), true);
break;
case ENTITY_ITEM:
$this->meta = (int) $this->data["meta"];
$this->stack = (int) $this->data["stack"];
$this->setHealth(5, "generic");
$this->server->schedule(5, array($this, "update"), array(), true);
break;
case ENTITY_MOB:
$this->setHealth($this->data["Health"], "generic");
//$this->server->schedule(5, array($this, "update"), array(), true);
//$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
break;
case ENTITY_OBJECT:
$this->x = isset($this->data["TileX"]) ? $this->data["TileX"]:$this->x;
$this->y = isset($this->data["TileY"]) ? $this->data["TileY"]:$this->y;
$this->z = isset($this->data["TileZ"]) ? $this->data["TileZ"]:$this->z;
$this->setHealth(1, "generic");
//$this->setName((isset($objects[$this->type]) ? $objects[$this->type]:$this->type));
break;
@ -399,7 +404,7 @@ class Entity extends stdClass{
"y" => (int) $this->y,
"z" => (int) $this->z,
"direction" => $this->getDirection(),
"title" => "Creepers",
"title" => $this->data["Motive"],
));
}
break;