mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 19:37:17 +00:00
Entity Motion packet (WiP)
This commit is contained in:
parent
f8179f0f7c
commit
862947ab6b
@ -220,6 +220,17 @@ class Player{
|
||||
"pitch" => $data->pitch,
|
||||
));
|
||||
break;
|
||||
case "entity.motion":
|
||||
/*if($data->eid === $this->eid){
|
||||
break;
|
||||
}
|
||||
$this->dataPacket(MC_SET_ENTITY_MOTION, array(
|
||||
"eid" => $data->eid,
|
||||
"speedX" => (int) ($data->speedX * 32000),
|
||||
"speedY" => (int) ($data->speedY * 32000),
|
||||
"speedZ" => (int) ($data->speedZ * 32000),
|
||||
));
|
||||
break;*/
|
||||
case "entity.remove":
|
||||
if($data->eid === $this->eid){
|
||||
break;
|
||||
@ -454,6 +465,7 @@ class Player{
|
||||
$this->evid[] = $this->server->event("server.chat", array($this, "eventHandler"));
|
||||
$this->evid[] = $this->server->event("entity.remove", array($this, "eventHandler"));
|
||||
$this->evid[] = $this->server->event("entity.move", array($this, "eventHandler"));
|
||||
$this->evid[] = $this->server->event("entity.motion", array($this, "eventHandler"));
|
||||
$this->evid[] = $this->server->event("entity.animate", array($this, "eventHandler"));
|
||||
$this->evid[] = $this->server->event("entity.event", array($this, "eventHandler"));
|
||||
$this->evid[] = $this->server->event("entity.metadata", array($this, "eventHandler"));
|
||||
|
@ -539,6 +539,7 @@ class PocketMinecraftServer{
|
||||
$version = $data[1];
|
||||
$size = strlen($data[2]);
|
||||
if($version !== CURRENT_PROTOCOL){
|
||||
console("[DEBUG] Incorrect protocol #$version from ".$packet["ip"].":".$packet["port"], true, true, 2);
|
||||
$this->send(0x1a, array(
|
||||
CURRENT_PROTOCOL,
|
||||
MAGIC,
|
||||
|
@ -487,6 +487,19 @@ class CustomPacketHandler{
|
||||
$this->raw .= Utils::writeMetadata($this->data["metadata"]);
|
||||
}
|
||||
break;
|
||||
case MC_SET_ENTITY_MOTION:
|
||||
if($this->c === false){
|
||||
$this->data["eid"] = Utils::readInt($this->get(4));
|
||||
$this->data["speedX"] = Utils::readShort($this->get(2));
|
||||
$this->data["speedY"] = Utils::readShort($this->get(2));
|
||||
$this->data["speedZ"] = Utils::readShort($this->get(2));
|
||||
}else{
|
||||
$this->raw .= Utils::writeInt($this->data["eid"]);
|
||||
$this->raw .= Utils::writeShort($this->data["speedX"]);
|
||||
$this->raw .= Utils::writeShort($this->data["speedY"]);
|
||||
$this->raw .= Utils::writeShort($this->data["speedZ"]);
|
||||
}
|
||||
break;
|
||||
case MC_SET_HEALTH:
|
||||
if($this->c === false){
|
||||
$this->data["health"] = Utils::readByte($this->get(1));
|
||||
|
@ -235,20 +235,22 @@ class Entity extends stdClass{
|
||||
$y = (int) round($this->y - 1);
|
||||
$z = (int) round($this->z - 0.5);
|
||||
if($this->speedX != 0){
|
||||
$this->x += $this->speedX;
|
||||
$this->x += $this->speedX * 4;
|
||||
}
|
||||
if($this->speedY != 0){
|
||||
$this->y += $this->speedY;
|
||||
$this->y += $this->speedY * 4;
|
||||
}
|
||||
if($this->speedZ != 0){
|
||||
$this->z += $this->speedZ;
|
||||
$this->z += $this->speedZ * 4;
|
||||
}
|
||||
$b = $this->server->api->level->getBlock($x, $y, $z);
|
||||
if(isset(Material::$transparent[$b[0]])){
|
||||
$this->speedY -= 0.32;
|
||||
$this->speedY -= 0.04 * 4;
|
||||
$this->server->api->dhandle("entity.motion", $this);
|
||||
}elseif($this->speedY < 0){
|
||||
$this->y = $y + 1;
|
||||
$this->speedY = 0;
|
||||
$this->server->api->dhandle("entity.motion", $this);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user