mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 03:06:55 +00:00
Updated Position to use Weak / strong references for Level objects
This commit is contained in:
@ -50,13 +50,13 @@ class Chest extends Spawnable{
|
||||
|
||||
public function getPair(){
|
||||
if($this->isPaired()){
|
||||
return $this->level->getTile(new Vector3((int) $this->namedtag->pairx, $this->y, (int) $this->namedtag->pairz));
|
||||
return $this->getLevel()->getTile(new Vector3((int) $this->namedtag->pairx, $this->y, (int) $this->namedtag->pairz));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function pairWith(Tile $tile){
|
||||
public function pairWith(Chest $tile){
|
||||
if($this->isPaired() or $tile->isPaired()){
|
||||
return false;
|
||||
}
|
||||
@ -69,6 +69,8 @@ class Chest extends Spawnable{
|
||||
|
||||
$this->spawnToAll();
|
||||
$tile->spawnToAll();
|
||||
|
||||
//TODO: Update to new events
|
||||
$this->server->handle("tile.update", $this);
|
||||
$this->server->handle("tile.update", $tile);
|
||||
|
||||
|
@ -65,7 +65,7 @@ trait Container{
|
||||
$slots = array();
|
||||
|
||||
if(is_array($player->windows[$id])){
|
||||
$all = $this->level->getPlayers();
|
||||
$all = $this->getLevel()->getPlayers();
|
||||
foreach($player->windows[$id] as $ob){
|
||||
$pk = new TileEventPacket();
|
||||
$pk->x = $ob->x;
|
||||
@ -90,7 +90,7 @@ trait Container{
|
||||
$pk->z = $this->z;
|
||||
$pk->case1 = 1;
|
||||
$pk->case2 = 2;
|
||||
Player::broadcastPacket($this->level->getPlayers(), $pk);
|
||||
Player::broadcastPacket($this->getLevel()->getPlayers(), $pk);
|
||||
for($s = 0; $s < Chest::SLOTS; ++$s){
|
||||
$slot = $this->getSlot($s);
|
||||
if($slot->getID() > Item::AIR and $slot->getCount() > 0){
|
||||
|
@ -70,9 +70,9 @@ class Furnace extends Tile{
|
||||
$fuel = Item::get(Item::AIR, 0, 0);
|
||||
}
|
||||
$this->setSlot(1, $fuel, false);
|
||||
$current = $this->level->getBlock($this);
|
||||
$current = $this->getLevel()->getBlock($this);
|
||||
if($current->getID() === Item::FURNACE){
|
||||
$this->level->setBlock($this, Block::get(Item::BURNING_FURNACE, $current->getMetadata()), true, false, true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Item::BURNING_FURNACE, $current->getMetadata()), true, false, true);
|
||||
}
|
||||
}
|
||||
if($this->namedtag->BurnTime > 0){
|
||||
@ -100,9 +100,9 @@ class Furnace extends Tile{
|
||||
}
|
||||
$ret = true;
|
||||
}else{
|
||||
$current = $this->level->getBlock($this);
|
||||
$current = $this->getLevel()->getBlock($this);
|
||||
if($current->getID() === Item::BURNING_FURNACE){
|
||||
$this->level->setBlock($this, Block::get(Item::FURNACE, $current->getMetadata()), true, false, true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Item::FURNACE, $current->getMetadata()), true, false, true);
|
||||
}
|
||||
$this->namedtag->CookTime = 0;
|
||||
$this->namedtag->BurnTime = 0;
|
||||
|
@ -27,7 +27,7 @@ abstract class Spawnable extends Tile{
|
||||
public abstract function spawnTo(Player $player);
|
||||
|
||||
public function spawnToAll(){
|
||||
foreach($this->level->getPlayers() as $player){
|
||||
foreach($this->getLevel()->getPlayers() as $player){
|
||||
if($player->eid !== false or $player->spawned !== true){
|
||||
$this->spawnTo($player);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ abstract class Tile extends Position{
|
||||
|
||||
public function __construct(Level $level, Compound $nbt){
|
||||
$this->server = Server::getInstance();
|
||||
$this->level = $level;
|
||||
$this->setLevel($level, true); //Strong reference
|
||||
$this->namedtag = $nbt;
|
||||
$this->closed = false;
|
||||
$this->name = "";
|
||||
|
Reference in New Issue
Block a user