mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 23:59:53 +00:00
Entity spawn packets
This commit is contained in:
parent
083bfcc83c
commit
84638098d0
@ -572,24 +572,24 @@ class Entity extends Position{
|
||||
$players = $this->server->api->player->getAll($this->level);
|
||||
if($this->player instanceof Player){
|
||||
unset($players[$this->player->CID]);
|
||||
$this->server->api->player->broadcastPacket($players, ProtocolInfo::MOVE_PLAYER_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"yaw" => $this->yaw,
|
||||
"pitch" => $this->pitch,
|
||||
"bodyYaw" => $this->yaw,
|
||||
));
|
||||
$pk = new MovePlayerPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
$pk->bodyYaw = $this->yaw;
|
||||
$this->server->api->player->broadcastPacket($players, $pk);
|
||||
}else{
|
||||
$this->server->api->player->broadcastPacket($players, ProtocolInfo::MOVE_ENTITY_POSROT_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"yaw" => $this->yaw,
|
||||
"pitch" => $this->pitch,
|
||||
));
|
||||
$pk = new MoveEntityPacket_PosRot;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
$this->server->api->player->broadcastPacket($players, $pk);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
@ -661,116 +661,135 @@ class Entity extends Position{
|
||||
if($this->player->connected !== true or $this->player->spawned === false){
|
||||
return false;
|
||||
}
|
||||
$player->dataPacket(ProtocolInfo::ADD_PLAYER_PACKET, array(
|
||||
"clientID" => 0,/*$this->player->clientID,*/
|
||||
"username" => $this->player->username,
|
||||
"eid" => $this->eid,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"yaw" => 0,
|
||||
"pitch" => 0,
|
||||
"unknown1" => 0,
|
||||
"unknown2" => 0,
|
||||
"metadata" => $this->getMetadata(),
|
||||
));
|
||||
$player->dataPacket(ProtocolInfo::PLAYER_EQUIPMENT_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"block" => $this->player->getSlot($this->player->slot)->getID(),
|
||||
"meta" => $this->player->getSlot($this->player->slot)->getMetadata(),
|
||||
"slot" => 0,
|
||||
));
|
||||
|
||||
$pk = new AddPlayerPacket;
|
||||
$pk->clientID = 0; //$this->player->clientID;
|
||||
$pk->username = $this->player->username;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->yaw = 0;
|
||||
$pk->pitch = 0;
|
||||
$pk->unknown1 = 0;
|
||||
$pk->unknown2 = 0;
|
||||
$pk->metadata = $this->getMetadata();
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new PlayerEquipmentPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->item = $this->player->getSlot($this->player->slot)->getID();
|
||||
$pk->meta = $this->player->getSlot($this->player->slot)->getMetadata();
|
||||
$pk->slot = 0;
|
||||
$player->dataPacket($pk);
|
||||
$this->player->sendArmor($player);
|
||||
break;
|
||||
case ENTITY_ITEM:
|
||||
$player->dataPacket(ProtocolInfo::ADD_ITEM_ENTITY_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"yaw" => $this->yaw,
|
||||
"pitch" => $this->pitch,
|
||||
"roll" => 0,
|
||||
"block" => $this->type,
|
||||
"meta" => $this->meta,
|
||||
"stack" => $this->stack,
|
||||
));
|
||||
$player->dataPacket(ProtocolInfo::SET_ENTITY_MOTION_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"speedX" => (int) ($this->speedX * 400),
|
||||
"speedY" => (int) ($this->speedY * 400),
|
||||
"speedZ" => (int) ($this->speedZ * 400),
|
||||
));
|
||||
$pk = new AddItemEntityPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
$pk->roll = 0;
|
||||
$pk->item = BlockAPI::getItem($this->type, $this->meta, $this->stack);
|
||||
$pk->metadata = $this->getMetadata();
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$player->dataPacket($pk);
|
||||
break;
|
||||
case ENTITY_MOB:
|
||||
$player->dataPacket(ProtocolInfo::ADD_MOB_PACKET, array(
|
||||
"type" => $this->type,
|
||||
"eid" => $this->eid,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"yaw" => 0,
|
||||
"pitch" => 0,
|
||||
"metadata" => $this->getMetadata(),
|
||||
));
|
||||
$player->dataPacket(ProtocolInfo::SET_ENTITY_MOTION_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"speedX" => (int) ($this->speedX * 400),
|
||||
"speedY" => (int) ($this->speedY * 400),
|
||||
"speedZ" => (int) ($this->speedZ * 400),
|
||||
));
|
||||
$pk = new AddMobPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->type = $this->type;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
$pk->metadata = $this->getMetadata();
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$player->dataPacket($pk);
|
||||
break;
|
||||
case ENTITY_OBJECT:
|
||||
if($this->type === OBJECT_PAINTING){
|
||||
$player->dataPacket(ProtocolInfo::ADD_PAINTING_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"x" => (int) $this->x,
|
||||
"y" => (int) $this->y,
|
||||
"z" => (int) $this->z,
|
||||
"direction" => $this->getDirection(),
|
||||
"title" => $this->data["Motive"],
|
||||
));
|
||||
$pk = new AddPaintingPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->x = (int) $this->x;
|
||||
$pk->y = (int) $this->y;
|
||||
$pk->z = (int) $this->z;
|
||||
$pk->direction = $this->getDirection();
|
||||
$pk->title = $this->data["Motive"];
|
||||
$player->dataPacket($pk);
|
||||
}elseif($this->type === OBJECT_PRIMEDTNT){
|
||||
$player->dataPacket(ProtocolInfo::ADD_ENTITY_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"type" => $this->type,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"did" => 0,
|
||||
));
|
||||
$pk = new AddEntityPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->type = $this->type;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->did = 0;
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$player->dataPacket($pk);
|
||||
}elseif($this->type === OBJECT_ARROW){
|
||||
$player->dataPacket(ProtocolInfo::ADD_ENTITY_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"type" => $this->type,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"did" => 0,
|
||||
));
|
||||
$player->dataPacket(ProtocolInfo::SET_ENTITY_MOTION_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"speedX" => (int) ($this->speedX * 400),
|
||||
"speedY" => (int) ($this->speedY * 400),
|
||||
"speedZ" => (int) ($this->speedZ * 400),
|
||||
));
|
||||
$pk = new AddEntityPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->type = $this->type;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->did = 0;
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
break;
|
||||
case ENTITY_FALLING:
|
||||
$player->dataPacket(ProtocolInfo::ADD_ENTITY_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"type" => $this->type,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"did" => -$this->data["Tile"],
|
||||
));
|
||||
$player->dataPacket(ProtocolInfo::SET_ENTITY_MOTION_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"speedX" => (int) ($this->speedX * 400),
|
||||
"speedY" => (int) ($this->speedY * 400),
|
||||
"speedZ" => (int) ($this->speedZ * 400),
|
||||
));
|
||||
$pk = new AddEntityPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->type = $this->type;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->did = -$this->data["Tile"];
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$player->dataPacket($pk);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -995,14 +1014,14 @@ class Entity extends Position{
|
||||
$this->updateMetadata();
|
||||
$this->dead = true;
|
||||
if($this->player instanceof Player){
|
||||
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), ProtocolInfo::MOVE_ENTITY_POSROT_PACKET, array(
|
||||
"eid" => $this->eid,
|
||||
"x" => -256,
|
||||
"y" => 128,
|
||||
"z" => -256,
|
||||
"yaw" => 0,
|
||||
"pitch" => 0,
|
||||
));
|
||||
$pk = new MoveEntityPacket_PosRot;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->x = -256;
|
||||
$pk->y = 128;
|
||||
$pk->z = -256;
|
||||
$pk->yaw = 0;
|
||||
$pk->pitch = 0;
|
||||
$this->server->api->player->broadcastPacket($this->level->players, $pk);
|
||||
}else{
|
||||
$this->server->api->dhandle("entity.event", array("entity" => $this, "event" => 3)); //Entity dead
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user