mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 19:37:17 +00:00
X,Z offset fixed
This commit is contained in:
parent
f1b2bc248f
commit
72c4cc7a30
@ -50,6 +50,13 @@ class LevelAPI{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getBlock($x, $y, $z){
|
||||
if($this->check()){
|
||||
return $this->map->getBlock($x, $y, $z);
|
||||
}
|
||||
return array(0,0);
|
||||
}
|
||||
|
||||
public function getOrderedChunk($X, $Z, $columnsPerPacket = 2){
|
||||
$columnsPerPacket = max(1, (int) $columnsPerPacket);
|
||||
$c = $this->getChunk($X, $Z);
|
||||
|
@ -146,7 +146,7 @@ class PlayerAPI{
|
||||
|
||||
public function getOffline($name){
|
||||
if(!file_exists(FILE_PATH."data/players/".$name.".dat")){
|
||||
console("[NOTICE] Player data not found for \"".$name."\", creating new");
|
||||
console("[NOTICE] Player data not found for \"".$name."\", creating new profile");
|
||||
$data = array(
|
||||
"spawn" => array(
|
||||
"x" => $this->server->spawn["x"],
|
||||
|
@ -75,7 +75,7 @@ class ChunkParser{
|
||||
private function getOffset($X, $Z, $sectors = 21){
|
||||
//$info = $this->getOffsetPosition($X, $Z);
|
||||
//return 4096 + (($info[1] * $info[0]) << 12) + (($info[2] * $data[0]) << 16);
|
||||
return 0x1000 + (($X * $sectors) << 12) + (($Z * $sectors) << 16);
|
||||
return 0x1000 + (($Z * $sectors) << 12) + (($X * $sectors) << 16);
|
||||
}
|
||||
|
||||
public function getChunk($X, $Z, $header = true){
|
||||
@ -163,7 +163,6 @@ class ChunkParser{
|
||||
$aX = $x - ($X << 4);
|
||||
$aZ = $z - ($Z << 4);
|
||||
$index = $aX + ($aZ << 4);
|
||||
console("[DEBUG] $x $y $z | $X $Z $index", true, true, 2);
|
||||
$block = ord($this->map[$X][$Z][0][$index]{$y});
|
||||
//$meta = $this->getOffset($X, $Z) + 4 + (($x << 6) + $y + ($z << 10));
|
||||
return array($block, 0);
|
||||
|
@ -375,21 +375,21 @@ class CustomPacketHandler{
|
||||
break;
|
||||
case MC_REQUEST_CHUNK:
|
||||
if($this->c === false){
|
||||
$this->data["z"] = Utils::readInt($this->get(4));
|
||||
$this->data["x"] = Utils::readInt($this->get(4));
|
||||
$this->data["z"] = Utils::readInt($this->get(4));
|
||||
}else{
|
||||
$this->raw .= Utils::writeInt($this->data["z"]);
|
||||
$this->raw .= Utils::writeInt($this->data["x"]);
|
||||
$this->raw .= Utils::writeInt($this->data["z"]);
|
||||
}
|
||||
break;
|
||||
case MC_CHUNK_DATA:
|
||||
if($this->c === false){
|
||||
$this->data["z"] = Utils::readInt($this->get(4));
|
||||
$this->data["x"] = Utils::readInt($this->get(4));
|
||||
$this->data["z"] = Utils::readInt($this->get(4));
|
||||
$this->data["data"] = $this->get(true);
|
||||
}else{
|
||||
$this->raw .= Utils::writeInt($this->data["z"]);
|
||||
$this->raw .= Utils::writeInt($this->data["x"]);
|
||||
$this->raw .= Utils::writeInt($this->data["z"]);
|
||||
$this->raw .= $this->data["data"];
|
||||
}
|
||||
break;
|
||||
|
@ -367,13 +367,17 @@ class Session{
|
||||
break;
|
||||
case MC_REMOVE_BLOCK:
|
||||
console("[DEBUG] EID ".$this->eid." broke block at X ".$data["x"]." Y ".$data["y"]." Z ".$data["z"], true, true, 2);
|
||||
$block = $this->server->api->level->getBlock($data["x"], $data["y"], $data["z"]);
|
||||
if($block[0] === 0){
|
||||
break;
|
||||
}
|
||||
$this->dataPacket(MC_ADD_ITEM_ENTITY, array(
|
||||
"eid" => $this->server->eidCnt++,
|
||||
"x" => $data["x"] + mt_rand(0, 100)/100,
|
||||
"y" => $data["y"],
|
||||
"z" => $data["z"] + mt_rand(0, 100)/100,
|
||||
"block" => 1,
|
||||
"meta" => 0,
|
||||
"block" => $block[0],
|
||||
"meta" => $block[1],
|
||||
"stack" => 1,
|
||||
));
|
||||
/*$this->send(0x84, array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user