mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Fixes
This commit is contained in:
parent
51bb3faf39
commit
ca74f4f0c1
@ -332,12 +332,16 @@ class CustomPacketHandler{
|
|||||||
$this->data["x"] = Utils::readInt($this->get(4));
|
$this->data["x"] = Utils::readInt($this->get(4));
|
||||||
$this->data["z"] = Utils::readInt($this->get(4));
|
$this->data["z"] = Utils::readInt($this->get(4));
|
||||||
$this->data["y"] = ord($this->get(1));
|
$this->data["y"] = ord($this->get(1));
|
||||||
|
$this->data["block"] = ord($this->get(1));
|
||||||
|
$this->data["meta"] = ord($this->get(1));
|
||||||
$this->data["face"] = Utils::readByte($this->get(1));
|
$this->data["face"] = Utils::readByte($this->get(1));
|
||||||
}else{
|
}else{
|
||||||
$this->raw .= Utils::writeInt($this->data["eid"]);
|
$this->raw .= Utils::writeInt($this->data["eid"]);
|
||||||
$this->raw .= Utils::writeInt($this->data["x"]);
|
$this->raw .= Utils::writeInt($this->data["x"]);
|
||||||
$this->raw .= Utils::writeInt($this->data["z"]);
|
$this->raw .= Utils::writeInt($this->data["z"]);
|
||||||
$this->raw .= chr($this->data["y"]);
|
$this->raw .= chr($this->data["y"]);
|
||||||
|
$this->raw .= chr($this->data["block"]);
|
||||||
|
$this->raw .= chr($this->data["meta"]);
|
||||||
$this->raw .= chr($this->data["face"]);
|
$this->raw .= chr($this->data["face"]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -356,17 +360,17 @@ class CustomPacketHandler{
|
|||||||
break;
|
break;
|
||||||
case MC_UPDATE_BLOCK:
|
case MC_UPDATE_BLOCK:
|
||||||
if($this->c === false){
|
if($this->c === false){
|
||||||
$this->data["block"] = Utils::readShort($this->get(2));
|
|
||||||
$this->data["meta"] = Utils::readShort($this->get(2));
|
|
||||||
$this->data["x"] = Utils::readInt($this->get(4));
|
$this->data["x"] = Utils::readInt($this->get(4));
|
||||||
$this->data["y"] = Utils::readInt($this->get(4));
|
|
||||||
$this->data["z"] = Utils::readInt($this->get(4));
|
$this->data["z"] = Utils::readInt($this->get(4));
|
||||||
|
$this->data["y"] = ord($this->get(1));
|
||||||
|
$this->data["block"] = ord($this->get(1));
|
||||||
|
$this->data["meta"] = ord($this->get(1));
|
||||||
}else{
|
}else{
|
||||||
$this->raw .= Utils::writeShort($this->data["block"]);
|
|
||||||
$this->raw .= Utils::writeShort($this->data["meta"]);
|
|
||||||
$this->raw .= Utils::writeInt($this->data["x"]);
|
$this->raw .= Utils::writeInt($this->data["x"]);
|
||||||
$this->raw .= Utils::writeInt($this->data["y"]);
|
|
||||||
$this->raw .= Utils::writeInt($this->data["z"]);
|
$this->raw .= Utils::writeInt($this->data["z"]);
|
||||||
|
$this->raw .= chr($this->data["y"]);
|
||||||
|
$this->raw .= chr($this->data["block"]);
|
||||||
|
$this->raw .= chr($this->data["meta"]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MC_REQUEST_CHUNK:
|
case MC_REQUEST_CHUNK:
|
||||||
@ -382,10 +386,7 @@ class CustomPacketHandler{
|
|||||||
if($this->c === false){
|
if($this->c === false){
|
||||||
$this->data["x"] = Utils::readInt($this->get(4));
|
$this->data["x"] = Utils::readInt($this->get(4));
|
||||||
$this->data["z"] = Utils::readInt($this->get(4));
|
$this->data["z"] = Utils::readInt($this->get(4));
|
||||||
//$this->data["unknown1"] = $this->get(WTF);
|
$this->data["data"] = $this->get(256);
|
||||||
$this->data["unknown1"] = Utils::readInt($this->get(4));
|
|
||||||
$this->data["unknown2"] = Utils::readInt($this->get(4));
|
|
||||||
//$this->data["unknown3"] = $this->get(WTF);
|
|
||||||
}else{
|
}else{
|
||||||
$this->raw .= Utils::writeInt($this->data["x"]);
|
$this->raw .= Utils::writeInt($this->data["x"]);
|
||||||
$this->raw .= Utils::writeInt($this->data["y"]);
|
$this->raw .= Utils::writeInt($this->data["y"]);
|
||||||
|
@ -99,6 +99,7 @@ class PocketMinecraftServer extends stdClass{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function query($sql, $fetch = false){
|
public function query($sql, $fetch = false){
|
||||||
|
console("[INTERNAL] [SQL] ".$sql, true, true, 3);
|
||||||
$result = $this->database->query($sql) or console("[ERROR] [SQL Error] ".$this->database->lastErrorMsg().". Query: ".$sql, true, true, 0);
|
$result = $this->database->query($sql) or console("[ERROR] [SQL Error] ".$this->database->lastErrorMsg().". Query: ".$sql, true, true, 0);
|
||||||
if($fetch === true and ($result !== false and $result !== true)){
|
if($fetch === true and ($result !== false and $result !== true)){
|
||||||
$result = $result->fetchArray(SQLITE3_ASSOC);
|
$result = $result->fetchArray(SQLITE3_ASSOC);
|
||||||
@ -328,7 +329,7 @@ class PocketMinecraftServer extends stdClass{
|
|||||||
$MTU = $data[3];
|
$MTU = $data[3];
|
||||||
$clientID = $data[4];
|
$clientID = $data[4];
|
||||||
$eid = $this->eidCnt++;
|
$eid = $this->eidCnt++;
|
||||||
$this->clients[$CID] = new Session($this, $clientID, $eid, $packet["ip"], $packet["port"]);
|
$this->clients[$CID] = new Session($this, $clientID, $eid, $packet["ip"], $packet["port"], $MTU);
|
||||||
$this->clients[$CID]->handle(0x07, $data);
|
$this->clients[$CID]->handle(0x07, $data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,10 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
|
|
||||||
class Session{
|
class Session{
|
||||||
private $server, $serverID, $timeout, $connected, $evid;
|
private $server, $timeout, $connected, $evid;
|
||||||
var $clientID, $ip, $port, $counter, $username, $eid, $data, $entity, $auth;
|
var $clientID, $ip, $port, $counter, $username, $eid, $data, $entity, $auth, $CID, $MTU;
|
||||||
function __construct($server, $clientID, $eid, $ip, $port){
|
function __construct($server, $clientID, $eid, $ip, $port, $MTU){
|
||||||
|
$this->MTU = $MTU;
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
$this->clientID = $clientID;
|
$this->clientID = $clientID;
|
||||||
$this->CID = $this->server->clientID($ip, $port);
|
$this->CID = $this->server->clientID($ip, $port);
|
||||||
@ -38,12 +39,11 @@ class Session{
|
|||||||
$this->ip = $ip;
|
$this->ip = $ip;
|
||||||
$this->entity = false;
|
$this->entity = false;
|
||||||
$this->port = $port;
|
$this->port = $port;
|
||||||
$this->serverID =& $this->server->serverID;
|
|
||||||
$this->timeout = microtime(true) + 25;
|
$this->timeout = microtime(true) + 25;
|
||||||
$this->evid = array();
|
$this->evid = array();
|
||||||
$this->evid[] = array("onTick", $this->server->event("onTick", array($this, "checkTimeout")));
|
$this->evid[] = array("onTick", $this->server->event("onTick", array($this, "checkTimeout")));
|
||||||
$this->evid[] = array("onClose", $this->server->event("onClose", array($this, "close")));
|
$this->evid[] = array("onClose", $this->server->event("onClose", array($this, "close")));
|
||||||
console("[DEBUG] New Session started with ".$ip.":".$port.". Client ID ".$this->clientID, true, true, 2);
|
console("[DEBUG] New Session started with ".$ip.":".$port.". MTU ".$this->MTU.", Client ID ".$this->clientID, true, true, 2);
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
$this->auth = false;
|
$this->auth = false;
|
||||||
$this->counter = array(0, 0);
|
$this->counter = array(0, 0);
|
||||||
@ -232,7 +232,7 @@ class Session{
|
|||||||
case 0x07:
|
case 0x07:
|
||||||
$this->send(0x08, array(
|
$this->send(0x08, array(
|
||||||
MAGIC,
|
MAGIC,
|
||||||
$this->serverID,
|
$this->server->serverID,
|
||||||
$this->port,
|
$this->port,
|
||||||
$data[3],
|
$data[3],
|
||||||
0,
|
0,
|
||||||
@ -374,10 +374,21 @@ class Session{
|
|||||||
console("[DEBUG] EID ".$this->eid." has now ".$data["block"].":".$data["meta"]." in their hands!", true, true, 2);
|
console("[DEBUG] EID ".$this->eid." has now ".$data["block"].":".$data["meta"]." in their hands!", true, true, 2);
|
||||||
break;
|
break;
|
||||||
case MC_REQUEST_CHUNK:
|
case MC_REQUEST_CHUNK:
|
||||||
|
$this->send(0x84, array(
|
||||||
|
$this->counter[0],
|
||||||
|
0x00,
|
||||||
|
array(
|
||||||
|
"id" => MC_CHUNK_DATA,
|
||||||
|
"x" => $data["x"],
|
||||||
|
"z" => $data["z"],
|
||||||
|
"data" => str_repeat("\x00", 256),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
++$this->counter[0];
|
||||||
console("[DEBUG] Chunk X ".$data["x"]." Z ".$data["z"]." requested", true, true, 2);
|
console("[DEBUG] Chunk X ".$data["x"]." Z ".$data["z"]." requested", true, true, 2);
|
||||||
break;
|
break;
|
||||||
case MC_REMOVE_BLOCK:
|
case MC_REMOVE_BLOCK:
|
||||||
$this->eventHandler("Blocks broken will not be saved", "onChat");
|
//$this->eventHandler("Blocks broken will not be saved", "onChat");
|
||||||
console("[DEBUG] EID ".$this->eid." broke block at X ".$data["x"]." Y ".$data["y"]." Z ".$data["z"], true, true, 2);
|
console("[DEBUG] EID ".$this->eid." broke block at X ".$data["x"]." Y ".$data["y"]." Z ".$data["z"], true, true, 2);
|
||||||
$this->send(0x84, array(
|
$this->send(0x84, array(
|
||||||
$this->counter[0],
|
$this->counter[0],
|
||||||
@ -394,6 +405,19 @@ class Session{
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
++$this->counter[0];
|
++$this->counter[0];
|
||||||
|
/*$this->send(0x84, array(
|
||||||
|
$this->counter[0],
|
||||||
|
0x00,
|
||||||
|
array(
|
||||||
|
"id" => MC_UPDATE_BLOCK,
|
||||||
|
"x" => $data["x"],
|
||||||
|
"y" => $data["y"],
|
||||||
|
"z" => $data["z"],
|
||||||
|
"block" => 56,
|
||||||
|
"meta" => 0,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
++$this->counter[0];*/
|
||||||
break;
|
break;
|
||||||
case MC_INTERACT:
|
case MC_INTERACT:
|
||||||
if($this->server->gamemode !== 1 and $this->server->difficulty > 0 and isset($this->server->entities[$data["target"]]) and Utils::distance($this->entity->position, $this->server->entities[$data["target"]]->position) <= 8){
|
if($this->server->gamemode !== 1 and $this->server->difficulty > 0 and isset($this->server->entities[$data["target"]]) and Utils::distance($this->entity->position, $this->server->entities[$data["target"]]->position) <= 8){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user