mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +00:00
BlockFactory: simplify get() code
This commit is contained in:
parent
4023a024ce
commit
686bf398d5
@ -957,18 +957,13 @@ class BlockFactory{
|
|||||||
throw new \InvalidArgumentException("Block meta value $meta is out of bounds");
|
throw new \InvalidArgumentException("Block meta value $meta is out of bounds");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Block|null $block */
|
$index = ($id << Block::INTERNAL_METADATA_BITS) | $meta;
|
||||||
$block = null;
|
if($index < 0 || $index >= $this->fullList->getSize()){
|
||||||
try{
|
|
||||||
$index = ($id << Block::INTERNAL_METADATA_BITS) | $meta;
|
|
||||||
if($this->fullList[$index] !== null){
|
|
||||||
$block = clone $this->fullList[$index];
|
|
||||||
}
|
|
||||||
}catch(\RuntimeException $e){
|
|
||||||
throw new \InvalidArgumentException("Block ID $id is out of bounds");
|
throw new \InvalidArgumentException("Block ID $id is out of bounds");
|
||||||
}
|
}
|
||||||
|
if($this->fullList[$index] !== null){
|
||||||
if($block === null){
|
$block = clone $this->fullList[$index];
|
||||||
|
}else{
|
||||||
$block = new UnknownBlock(new BID($id, $meta), BlockBreakInfo::instant());
|
$block = new UnknownBlock(new BID($id, $meta), BlockBreakInfo::instant());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user