mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Player Entities!!
This commit is contained in:
@ -192,9 +192,7 @@ class CustomPacketHandler{
|
||||
$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["yaw"] = Utils::readFloat($this->get(4));
|
||||
$this->data["pitch"] = Utils::readFloat($this->get(4));
|
||||
$this->data["metadata"] = $this->get(true);
|
||||
$this->data["metadata"] = Utils::readMetadata($this->get(true));
|
||||
}else{
|
||||
$this->raw .= Utils::writeLong($this->data["clientID"]);
|
||||
$this->raw .= Utils::writeShort(strlen($this->data["username"])).$this->data["username"];
|
||||
@ -202,9 +200,11 @@ class CustomPacketHandler{
|
||||
$this->raw .= Utils::writeFloat($this->data["x"]);
|
||||
$this->raw .= Utils::writeFloat($this->data["y"]);
|
||||
$this->raw .= Utils::writeFloat($this->data["z"]);
|
||||
$this->raw .= Utils::writeFloat($this->data["yaw"]);
|
||||
$this->raw .= Utils::writeFloat($this->data["pitch"]);
|
||||
$this->raw .= "\x21\x2c\x01\x10"."\x7f";
|
||||
$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_REMOVE_ENTITY:
|
||||
|
@ -27,8 +27,8 @@ the Free Software Foundation, either version 3 of the License, or
|
||||
|
||||
|
||||
class Session{
|
||||
protected $server, $serverID, $timeout, $connected, $evid;
|
||||
var $clientID, $ip, $port, $counter, $username, $eid, $data;
|
||||
private $server, $serverID, $timeout, $connected, $evid;
|
||||
var $clientID, $ip, $port, $counter, $username, $eid, $data, $entity;
|
||||
function __construct($server, $clientID, $eid, $ip, $port){
|
||||
$this->server = $server;
|
||||
$this->clientID = $clientID;
|
||||
@ -140,8 +140,6 @@ class Session{
|
||||
"x" => $data["x"],
|
||||
"y" => $data["y"],
|
||||
"z" => $data["z"],
|
||||
"yaw" => $data["yaw"],
|
||||
"pitch" => $data["pitch"],
|
||||
),
|
||||
));
|
||||
++$this->counter[0];
|
||||
@ -303,8 +301,6 @@ class Session{
|
||||
"x" => $this->data["spawn"]["x"],
|
||||
"y" => $this->data["spawn"]["y"],
|
||||
"z" => $this->data["spawn"]["z"],
|
||||
"yaw" => $this->data["spawn"]["yaw"],
|
||||
"pitch" => $this->data["spawn"]["pitch"],
|
||||
));
|
||||
foreach($this->server->entities as $entity){
|
||||
if($entity->eid !== $this->eid){
|
||||
|
@ -78,6 +78,104 @@ class Utils{
|
||||
public static function writeTriad($value){
|
||||
return substr(pack("N", $value), 1);
|
||||
}
|
||||
|
||||
public static function writeMetadata($data){
|
||||
$m = "";
|
||||
foreach($data as $bottom => $d){
|
||||
$m .= chr(($d["type"] << 5) & (0xE0 | $bottom));
|
||||
switch($d["type"]){
|
||||
case 0:
|
||||
$m .= Utils::writeByte($data["value"]);
|
||||
break;
|
||||
case 1:
|
||||
$m .= Utils::writeLShort($data["value"]);
|
||||
break;
|
||||
case 2:
|
||||
$m .= Utils::writeLInt($data["value"]);
|
||||
break;
|
||||
case 3:
|
||||
$m .= Utils::writeLFloat($data["value"]);
|
||||
break;
|
||||
case 4:
|
||||
$m .= Utils::writeLShort(strlen($data["value"]));
|
||||
$m .= $data["value"];
|
||||
break;
|
||||
case 5:
|
||||
$m .= Utils::writeLShort($data["value"][0]);
|
||||
$m .= Utils::writeByte($data["value"][1]);
|
||||
$m .= Utils::writeLShort($data["value"][2]);
|
||||
break;
|
||||
case 6:
|
||||
for($i=0; $i < 3; ++$i){
|
||||
$m .= Utils::writeLInt($data["value"][$i]);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
$m .= "\x7f";
|
||||
return $m;
|
||||
}
|
||||
|
||||
public static function readMetadata($value, $types = false){
|
||||
$offset = 0;
|
||||
$m = array();
|
||||
$b = ord($value{$offset});
|
||||
++$offset;
|
||||
while($b !== 127){
|
||||
$bottom = $b & 0x1F;
|
||||
$type = $b >> 5;
|
||||
switch($type){
|
||||
case 0:
|
||||
$r = Utils::readByte($value{$offset});
|
||||
++$offset;
|
||||
break;
|
||||
case 1:
|
||||
$r = Utils::readLShort(substr($value, $offset, 2));
|
||||
$offset += 2;
|
||||
break;
|
||||
case 2:
|
||||
$r = Utils::readLInt(substr($value, $offset, 4));
|
||||
$offset += 4;
|
||||
break;
|
||||
case 3:
|
||||
$r = Utils::readLFloat(substr($value, $offset, 4));
|
||||
$offset += 4;
|
||||
break;
|
||||
case 4:
|
||||
$len = Utils::readLShort(substr($value, $offset, 2));
|
||||
$offset += 2;
|
||||
$r = substr($value, $offset, $len);
|
||||
$offset += $len;
|
||||
break;
|
||||
case 5:
|
||||
$r = array();
|
||||
$r[] = Utils::readLShort(substr($value, $offset, 2));
|
||||
$offset += 2;
|
||||
$r[] = Utils::readByte($value{$offset});
|
||||
++$offset;
|
||||
$r[] = Utils::readLShort(substr($value, $offset, 2));
|
||||
$offset += 2;
|
||||
break;
|
||||
case 6:
|
||||
$r = array();
|
||||
for($i=0; $i < 3; ++$i){
|
||||
$r[] = Utils::readLInt(substr($value, $offset, 4));
|
||||
$offset += 4;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
if($types === true){
|
||||
$m[$bottom] = array($r, $type);
|
||||
}else{
|
||||
$m[$bottom] = $r;
|
||||
}
|
||||
$b = ord($value{$offset});
|
||||
++$offset;
|
||||
}
|
||||
return $m;
|
||||
}
|
||||
|
||||
public static function readDataArray($str, $len = 10, &$offset = null){
|
||||
$data = array();
|
||||
|
Reference in New Issue
Block a user