mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Changes in Entity events
This commit is contained in:
parent
683c05f206
commit
c1aec49ad1
@ -204,7 +204,7 @@ class BlockAPI{
|
|||||||
$data["x"] += mt_rand(2, 8) / 10;
|
$data["x"] += mt_rand(2, 8) / 10;
|
||||||
$data["y"] += 0.19;
|
$data["y"] += 0.19;
|
||||||
$data["z"] += mt_rand(2, 8) / 10;
|
$data["z"] += mt_rand(2, 8) / 10;
|
||||||
if($this->server->api->handle("item.drop", $data) !== false){
|
if($this->server->api->handle("block.drop", $data) !== false){
|
||||||
for($count = $stack; $count > 0; ){
|
for($count = $stack; $count > 0; ){
|
||||||
$data["stack"] = min(64, $count);
|
$data["stack"] = min(64, $count);
|
||||||
$count -= $data["stack"];
|
$count -= $data["stack"];
|
||||||
|
@ -77,7 +77,7 @@ class Entity extends stdClass{
|
|||||||
|
|
||||||
public function update(){
|
public function update(){
|
||||||
if($this->class === ENTITY_ITEM and $this->closed === false){
|
if($this->class === ENTITY_ITEM and $this->closed === false){
|
||||||
$this->server->api->dhandle("entity.move", $this->eid);
|
$this->server->api->dhandle("entity.move", $this);
|
||||||
$player = $this->server->query("SELECT EID FROM entities WHERE class == ".ENTITY_PLAYER." AND abs(x - {$this->x}) <= 1.5 AND abs(y - {$this->y}) <= 1.5 AND abs(z - {$this->z}) <= 1.5 LIMIT 1;", true);
|
$player = $this->server->query("SELECT EID FROM entities WHERE class == ".ENTITY_PLAYER." AND abs(x - {$this->x}) <= 1.5 AND abs(y - {$this->y}) <= 1.5 AND abs(z - {$this->z}) <= 1.5 LIMIT 1;", true);
|
||||||
if($player !== true and $player !== false){
|
if($player !== true and $player !== false){
|
||||||
if($this->server->api->dhandle("player.item.pick", array(
|
if($this->server->api->dhandle("player.item.pick", array(
|
||||||
@ -163,8 +163,8 @@ class Entity extends stdClass{
|
|||||||
|
|
||||||
public function close(){
|
public function close(){
|
||||||
if($this->closed === false){
|
if($this->closed === false){
|
||||||
$this->server->query("DELETE FROM entities WHERE EID = ".$this->eid.";");
|
$this->server->query("DELETE FROM entities WHERE EID = ".$this.";");
|
||||||
$this->server->api->dhandle("entity.remove", $this->eid);
|
$this->server->api->dhandle("entity.remove", $this);
|
||||||
$this->closed = true;
|
$this->closed = true;
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
}
|
}
|
||||||
|
@ -129,17 +129,16 @@ class Player{
|
|||||||
$this->dataPacket(MC_UPDATE_BLOCK, $data);
|
$this->dataPacket(MC_UPDATE_BLOCK, $data);
|
||||||
break;
|
break;
|
||||||
case "entity.move":
|
case "entity.move":
|
||||||
if($data === $this->eid){
|
if($data->eid === $this->eid){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$entity = $this->server->entities[$data];
|
|
||||||
$this->dataPacket(MC_MOVE_ENTITY_POSROT, array(
|
$this->dataPacket(MC_MOVE_ENTITY_POSROT, array(
|
||||||
"eid" => $data,
|
"eid" => $data->eid,
|
||||||
"x" => $entity->x,
|
"x" => $data->x,
|
||||||
"y" => $entity->y,
|
"y" => $data->y,
|
||||||
"z" => $entity->z,
|
"z" => $data->z,
|
||||||
"yaw" => $entity->yaw,
|
"yaw" => $data->yaw,
|
||||||
"pitch" => $entity->pitch,
|
"pitch" => $data->pitch,
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
case "entity.remove":
|
case "entity.remove":
|
||||||
@ -241,6 +240,13 @@ class Player{
|
|||||||
$this->send(0xc0, array(1, true, $data[0]));
|
$this->send(0xc0, array(1, true, $data[0]));
|
||||||
}
|
}
|
||||||
switch($data["id"]){
|
switch($data["id"]){
|
||||||
|
|
||||||
|
case MC_KEEP_ALIVE:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
|
||||||
|
break;
|
||||||
case MC_DISCONNECT:
|
case MC_DISCONNECT:
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
$this->close("client disconnect");
|
$this->close("client disconnect");
|
||||||
@ -328,7 +334,7 @@ class Player{
|
|||||||
case MC_MOVE_PLAYER:
|
case MC_MOVE_PLAYER:
|
||||||
if(is_object($this->entity)){
|
if(is_object($this->entity)){
|
||||||
$this->entity->setPosition($data["x"], $data["y"], $data["z"], $data["yaw"], $data["pitch"]);
|
$this->entity->setPosition($data["x"], $data["y"], $data["z"], $data["yaw"], $data["pitch"]);
|
||||||
$this->server->api->dhandle("entity.move", $this->eid);
|
$this->server->api->dhandle("entity.move", $this->entity);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MC_PLAYER_EQUIPMENT:
|
case MC_PLAYER_EQUIPMENT:
|
||||||
@ -359,9 +365,6 @@ class Player{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->server->handle("player.block.action", $data);
|
$this->server->handle("player.block.action", $data);
|
||||||
break;
|
|
||||||
case MC_PLACE_BLOCK:
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MC_REMOVE_BLOCK:
|
case MC_REMOVE_BLOCK:
|
||||||
$data["eid"] = $this->eid;
|
$data["eid"] = $this->eid;
|
||||||
@ -388,7 +391,9 @@ class Player{
|
|||||||
case MC_DROP_ITEM:
|
case MC_DROP_ITEM:
|
||||||
$this->server->api->block->drop($this->entity->x, $this->entity->y, $this->entity->z, $data["block"], $data["meta"], $data["stack"]);
|
$this->server->api->block->drop($this->entity->x, $this->entity->y, $this->entity->z, $data["block"], $data["meta"], $data["stack"]);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
console("[INTERNAL] Unhandled 0x".dechex($data["id"])." Data Packet for Client ID ".$this->clientID.": ".print_r($data), true, true, 3);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ class PocketMinecraftServer extends stdClass{
|
|||||||
$this->chat(false, "Stopping server...");
|
$this->chat(false, "Stopping server...");
|
||||||
$this->save(true);
|
$this->save(true);
|
||||||
$this->stop = true;
|
$this->stop = true;
|
||||||
$this->trigger("server.close");
|
$this->trigger("server.close", $reason);
|
||||||
$this->interface->close();
|
$this->interface->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,6 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
//Protocol Version: 5
|
//Protocol Version: 5
|
||||||
|
|
||||||
|
|
||||||
define("MC_KEEP_ALIVE", 0x00);
|
|
||||||
|
|
||||||
define("MC_KEEP_ALIVE", 0x00);
|
define("MC_KEEP_ALIVE", 0x00);
|
||||||
|
|
||||||
define("MC_CLIENT_CONNECT", 0x09);
|
define("MC_CLIENT_CONNECT", 0x09);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user