Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
update chunk functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MakStashkevich committed Dec 21, 2019
1 parent 53b341a commit 2607831
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions client/level/Level.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,26 @@ function addChunk(Chunk $chunk): bool
*/
function getBlockIdAt(float $x, float $y, float $z): int
{
$this->blockToInteger($x, $y, $z);
if ($this->isChunk($chunkX = $x >> 4, $chunkZ = $z >> 4)) {
$chunk = $this->getChunk($chunkX, $chunkZ);
return $chunk->getBlockId($x, $y, $z);
}
return 0;
}

/**
* @param float $x
* @param float $y
* @param float $z
*/
function blockToInteger(float &$x, float &$y, float &$z)
{
$x = (int)$x;
$y = (int)$y;
$z = (int)$z;
}

/**
* @param float $x
* @param float $y
Expand All @@ -76,6 +89,7 @@ function getBlockIdAt(float $x, float $y, float $z): int
*/
function getBlockDataAt(float $x, float $y, float $z): int
{
$this->blockToInteger($x, $y, $z);
if ($this->isChunk($chunkX = $x >> 4, $chunkZ = $z >> 4)) {
$chunk = $this->getChunk($chunkX, $chunkZ);
return $chunk->getBlockData($x, $y, $z);
Expand All @@ -90,6 +104,7 @@ function getBlockDataAt(float $x, float $y, float $z): int
*/
function getHighestBlockAt(float $x, float $z): int
{
$this->blockToInteger($x, $y, $z);
if ($this->isChunk($chunkX = $x >> 4, $chunkZ = $z >> 4)) {
$chunk = $this->getChunk($chunkX, $chunkZ);
return $chunk->getHighestBlockAt($x, $z);
Expand Down

0 comments on commit 2607831

Please sign in to comment.