mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Position: add getLevelNonNull()
this allows assuming that a position has a valid world in places where it's never expected to not be valid. Since this is the vast majority of usages, it eliminates a lot of possible null-pointer warnings given by static analysers. TODO: Consider whether we can make Position->getLevel/World use this behaviour out of the box in the next major version.
This commit is contained in:
@ -121,7 +121,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
* @return void
|
||||
*/
|
||||
protected function checkPairing(){
|
||||
if($this->isPaired() and !$this->getLevel()->isInLoadedTerrain(new Vector3($this->pairX, $this->y, $this->pairZ))){
|
||||
if($this->isPaired() and !$this->getLevelNonNull()->isInLoadedTerrain(new Vector3($this->pairX, $this->y, $this->pairZ))){
|
||||
//paired to a tile in an unloaded chunk
|
||||
$this->doubleInventory = null;
|
||||
|
||||
@ -160,7 +160,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
|
||||
public function getPair() : ?Chest{
|
||||
if($this->isPaired()){
|
||||
$tile = $this->getLevel()->getTileAt($this->pairX, $this->y, $this->pairZ);
|
||||
$tile = $this->getLevelNonNull()->getTileAt($this->pairX, $this->y, $this->pairZ);
|
||||
if($tile instanceof Chest){
|
||||
return $tile;
|
||||
}
|
||||
|
Reference in New Issue
Block a user