Fixed possible Level::getBlock() crash

This commit is contained in:
Shoghi Cervantes 2014-08-27 18:11:23 +02:00
parent afa98866e0
commit 9e5e4fb362
2 changed files with 3 additions and 3 deletions

View File

@ -733,8 +733,8 @@ class Level implements ChunkManager, Metadatable{
public function getBlock(Vector3 $pos){
$blockId = 0;
$meta = 0;
if($pos->y >= 0 and $pos->y < 128){
$this->getChunkAt($pos->x >> 4, $pos->z >> 4, true)->getBlock($pos->x & 0x0f, $pos->y & 0x7f, $pos->z & 0x0f, $blockId, $meta);
if($pos->y >= 0 and $pos->y < 128 and ($chunk = $this->getChunkAt($pos->x >> 4, $pos->z >> 4, true)) !== null){
$chunk->getBlock($pos->x & 0x0f, $pos->y & 0x7f, $pos->z & 0x0f, $blockId, $meta);
}
if($blockId === 0){

View File

@ -105,7 +105,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
if(!isset($nbt->id)){
continue;
}
//TODO: add all entities
if($nbt->id instanceof String){ //New format
switch($nbt["id"]){