mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-14 22:01:59 +00:00
Added more Events and Handlers
This commit is contained in:
parent
e4d71949e3
commit
d733eb6b4a
@ -576,7 +576,7 @@ class BlockAPI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function updateBlockRemote($data, $event){
|
public function updateBlockRemote($data, $event){
|
||||||
if($event !== "world.block.update"){
|
if($event !== "block.update"){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->updateBlock($data["x"], $data["y"], $data["z"], isset($data["type"]) ? $data["type"]:BLOCK_UPDATE_RANDOM);
|
$this->updateBlock($data["x"], $data["y"], $data["z"], isset($data["type"]) ? $data["type"]:BLOCK_UPDATE_RANDOM);
|
||||||
|
@ -61,6 +61,7 @@ class EntityAPI{
|
|||||||
public function add($class, $type = 0, $data = array()){
|
public function add($class, $type = 0, $data = array()){
|
||||||
$eid = $this->server->eidCnt++;
|
$eid = $this->server->eidCnt++;
|
||||||
$this->server->entities[$eid] = new Entity($this->server, $eid, $class, $type, $data);
|
$this->server->entities[$eid] = new Entity($this->server, $eid, $class, $type, $data);
|
||||||
|
$this->server->handle("entity.add", $this->server->entities[$eid]);
|
||||||
return $this->server->entities[$eid];
|
return $this->server->entities[$eid];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class LevelAPI{
|
|||||||
public function setBlock($x, $y, $z, $block, $meta = 0, $update = true){
|
public function setBlock($x, $y, $z, $block, $meta = 0, $update = true){
|
||||||
$this->map->setBlock($x, $y, $z, $block, $meta);
|
$this->map->setBlock($x, $y, $z, $block, $meta);
|
||||||
$this->heightMap[$z][$x] = $this->map->getFloor($x, $z);
|
$this->heightMap[$z][$x] = $this->map->getFloor($x, $z);
|
||||||
if($this->server->api->dhandle("world.block.change", array(
|
if($this->server->api->dhandle("block.change", array(
|
||||||
"x" => $x,
|
"x" => $x,
|
||||||
"y" => $y,
|
"y" => $y,
|
||||||
"z" => $z,
|
"z" => $z,
|
||||||
|
@ -83,7 +83,7 @@ class Entity extends stdClass{
|
|||||||
$this->server->api->dhandle("entity.move", $this);
|
$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.pickup", array(
|
||||||
"eid" => $player["EID"],
|
"eid" => $player["EID"],
|
||||||
"block" => $this->type,
|
"block" => $this->type,
|
||||||
"meta" => $this->meta,
|
"meta" => $this->meta,
|
||||||
|
@ -92,6 +92,7 @@ class Player{
|
|||||||
|
|
||||||
public function close($reason = "", $msg = true){
|
public function close($reason = "", $msg = true){
|
||||||
if($this->connected === true){
|
if($this->connected === true){
|
||||||
|
$this->server->dhandle("player.quit", $this);
|
||||||
$reason = $reason == "" ? "server stop":$reason;
|
$reason = $reason == "" ? "server stop":$reason;
|
||||||
$this->save();
|
$this->save();
|
||||||
$this->eventHandler(new Container("You have been kicked. Reason: ".$reason), "server.chat");
|
$this->eventHandler(new Container("You have been kicked. Reason: ".$reason), "server.chat");
|
||||||
@ -344,6 +345,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->dhandle("player.move", $this->entity);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MC_PLAYER_EQUIPMENT:
|
case MC_PLAYER_EQUIPMENT:
|
||||||
@ -384,9 +386,11 @@ class Player{
|
|||||||
break;
|
break;
|
||||||
case MC_INTERACT:
|
case MC_INTERACT:
|
||||||
if(isset($this->server->entities[$data["target"]]) and Utils::distance($this->entity->position, $this->server->entities[$data["target"]]->position) <= 8){
|
if(isset($this->server->entities[$data["target"]]) and Utils::distance($this->entity->position, $this->server->entities[$data["target"]]->position) <= 8){
|
||||||
console("[DEBUG] EID ".$this->eid." attacked EID ".$data["target"], true, true, 2);
|
if($this->handle("player.interact", $data) !== false){
|
||||||
if($this->server->gamemode !== 1 and $this->server->difficulty > 0){
|
console("[DEBUG] EID ".$this->eid." attacked EID ".$data["target"], true, true, 2);
|
||||||
$this->server->api->entity->harm($data["target"], $this->server->difficulty, $this->eid);
|
if($this->server->gamemode !== 1 and $this->server->difficulty > 0){
|
||||||
|
$this->server->api->entity->harm($data["target"], $this->server->difficulty, $this->eid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -406,7 +410,9 @@ class Player{
|
|||||||
//$this->entity->setHealth($data["health"], "client");
|
//$this->entity->setHealth($data["health"], "client");
|
||||||
break;
|
break;
|
||||||
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"]);
|
if($this->server->handle("player.drop", $data) !== false){
|
||||||
|
$this->server->api->block->drop($this->entity->x, $this->entity->y, $this->entity->z, $data["block"], $data["meta"], $data["stack"]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console("[DEBUG] Unhandled 0x".dechex($data["id"])." Data Packet for Client ID ".$this->clientID.": ".print_r($data, true), true, true, 2);
|
console("[DEBUG] Unhandled 0x".dechex($data["id"])." Data Packet for Client ID ".$this->clientID.": ".print_r($data, true), true, true, 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user