mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Refactor Block & Tile: getPos() to getPosition() (#4395)
this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
This commit is contained in:
@ -55,7 +55,7 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
$this->inventory = new ChestInventory($this->pos);
|
||||
$this->inventory = new ChestInventory($this->position);
|
||||
}
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
@ -63,8 +63,8 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
$pairX = $pairXTag->getValue();
|
||||
$pairZ = $pairZTag->getValue();
|
||||
if(
|
||||
($this->pos->x === $pairX and abs($this->pos->z - $pairZ) === 1) or
|
||||
($this->pos->z === $pairZ and abs($this->pos->x - $pairX) === 1)
|
||||
($this->position->x === $pairX and abs($this->position->z - $pairZ) === 1) or
|
||||
($this->position->z === $pairZ and abs($this->position->x - $pairX) === 1)
|
||||
){
|
||||
$this->pairX = $pairX;
|
||||
$this->pairZ = $pairZ;
|
||||
@ -99,7 +99,7 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
$this->inventory->removeAllViewers();
|
||||
|
||||
if($this->doubleInventory !== null){
|
||||
if($this->isPaired() and $this->pos->getWorld()->isChunkLoaded($this->pairX >> 4, $this->pairZ >> 4)){
|
||||
if($this->isPaired() and $this->position->getWorld()->isChunkLoaded($this->pairX >> 4, $this->pairZ >> 4)){
|
||||
$this->doubleInventory->removeAllViewers();
|
||||
if(($pair = $this->getPair()) !== null){
|
||||
$pair->doubleInventory = null;
|
||||
@ -135,7 +135,7 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
}
|
||||
|
||||
protected function checkPairing() : void{
|
||||
if($this->isPaired() and !$this->pos->getWorld()->isInLoadedTerrain(new Vector3($this->pairX, $this->pos->y, $this->pairZ))){
|
||||
if($this->isPaired() and !$this->position->getWorld()->isInLoadedTerrain(new Vector3($this->pairX, $this->position->y, $this->pairZ))){
|
||||
//paired to a tile in an unloaded chunk
|
||||
$this->doubleInventory = null;
|
||||
|
||||
@ -148,7 +148,7 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
if($pair->doubleInventory !== null){
|
||||
$this->doubleInventory = $pair->doubleInventory;
|
||||
}else{
|
||||
if(($pair->getPos()->x + ($pair->getPos()->z << 15)) > ($this->pos->x + ($this->pos->z << 15))){ //Order them correctly
|
||||
if(($pair->getPosition()->x + ($pair->getPosition()->z << 15)) > ($this->position->x + ($this->position->z << 15))){ //Order them correctly
|
||||
$this->doubleInventory = $pair->doubleInventory = new DoubleChestInventory($pair->inventory, $this->inventory);
|
||||
}else{
|
||||
$this->doubleInventory = $pair->doubleInventory = new DoubleChestInventory($this->inventory, $pair->inventory);
|
||||
@ -171,7 +171,7 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
|
||||
public function getPair() : ?Chest{
|
||||
if($this->isPaired()){
|
||||
$tile = $this->pos->getWorld()->getTileAt($this->pairX, $this->pos->y, $this->pairZ);
|
||||
$tile = $this->position->getWorld()->getTileAt($this->pairX, $this->position->y, $this->pairZ);
|
||||
if($tile instanceof Chest){
|
||||
return $tile;
|
||||
}
|
||||
@ -195,11 +195,11 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
}
|
||||
|
||||
private function createPair(Chest $tile) : void{
|
||||
$this->pairX = $tile->getPos()->x;
|
||||
$this->pairZ = $tile->getPos()->z;
|
||||
$this->pairX = $tile->getPosition()->x;
|
||||
$this->pairZ = $tile->getPosition()->z;
|
||||
|
||||
$tile->pairX = $this->getPos()->x;
|
||||
$tile->pairZ = $this->getPos()->z;
|
||||
$tile->pairX = $this->getPosition()->x;
|
||||
$tile->pairZ = $this->getPosition()->z;
|
||||
}
|
||||
|
||||
public function unpair() : bool{
|
||||
|
Reference in New Issue
Block a user