Level: Fixed some unnecessary double uses of Level::blockHash()

This commit is contained in:
Dylan K. Taylor 2017-12-13 11:25:36 +00:00
parent 131a6a4d19
commit dc064dfa2e

View File

@ -1612,7 +1612,7 @@ class Level implements ChunkManager, Metadatable{
$block->position($pos);
$block->clearCaches();
unset($this->blockCache[Level::blockHash($pos->x, $pos->y, $pos->z)]);
unset($this->blockCache[$blockHash = Level::blockHash($pos->x, $pos->y, $pos->z)]);
$index = Level::chunkHash($pos->x >> 4, $pos->z >> 4);
@ -1624,7 +1624,7 @@ class Level implements ChunkManager, Metadatable{
$this->changedBlocks[$index] = [];
}
$this->changedBlocks[$index][Level::blockHash($block->x, $block->y, $block->z)] = clone $block;
$this->changedBlocks[$index][$blockHash] = clone $block;
}
foreach($this->getChunkLoaders($pos->x >> 4, $pos->z >> 4) as $loader){
@ -2146,13 +2146,13 @@ class Level implements ChunkManager, Metadatable{
* @param int $id 0-255
*/
public function setBlockIdAt(int $x, int $y, int $z, int $id){
unset($this->blockCache[Level::blockHash($x, $y, $z)]);
unset($this->blockCache[$blockHash = Level::blockHash($x, $y, $z)]);
$this->getChunk($x >> 4, $z >> 4, true)->setBlockId($x & 0x0f, $y, $z & 0x0f, $id & 0xff);
if(!isset($this->changedBlocks[$index = Level::chunkHash($x >> 4, $z >> 4)])){
$this->changedBlocks[$index] = [];
}
$this->changedBlocks[$index][Level::blockHash($x, $y, $z)] = $v = new Vector3($x, $y, $z);
$this->changedBlocks[$index][$blockHash] = $v = new Vector3($x, $y, $z);
foreach($this->getChunkLoaders($x >> 4, $z >> 4) as $loader){
$loader->onBlockChanged($v);
}
@ -2208,13 +2208,13 @@ class Level implements ChunkManager, Metadatable{
* @param int $data 0-15
*/
public function setBlockDataAt(int $x, int $y, int $z, int $data){
unset($this->blockCache[Level::blockHash($x, $y, $z)]);
unset($this->blockCache[$blockHash = Level::blockHash($x, $y, $z)]);
$this->getChunk($x >> 4, $z >> 4, true)->setBlockData($x & 0x0f, $y, $z & 0x0f, $data & 0x0f);
if(!isset($this->changedBlocks[$index = Level::chunkHash($x >> 4, $z >> 4)])){
$this->changedBlocks[$index] = [];
}
$this->changedBlocks[$index][Level::blockHash($x, $y, $z)] = $v = new Vector3($x, $y, $z);
$this->changedBlocks[$index][$blockHash] = $v = new Vector3($x, $y, $z);
foreach($this->getChunkLoaders($x >> 4, $z >> 4) as $loader){
$loader->onBlockChanged($v);
}