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