mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Avoid more $this refs on long-life closures
This commit is contained in:
parent
c356abb917
commit
7b2c6c5ceb
@ -54,8 +54,8 @@ class BrewingStand extends Spawnable implements Container, Nameable{
|
|||||||
public function __construct(World $world, Vector3 $pos){
|
public function __construct(World $world, Vector3 $pos){
|
||||||
parent::__construct($world, $pos);
|
parent::__construct($world, $pos);
|
||||||
$this->inventory = new BrewingStandInventory($this->pos);
|
$this->inventory = new BrewingStandInventory($this->pos);
|
||||||
$this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(function(Inventory $unused) : void{
|
$this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(static function(Inventory $unused) use ($world, $pos) : void{
|
||||||
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, 1);
|
$world->scheduleDelayedBlockUpdate($pos, 1);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@ class Furnace extends Spawnable implements Container, Nameable{
|
|||||||
parent::__construct($world, $pos);
|
parent::__construct($world, $pos);
|
||||||
$this->inventory = new FurnaceInventory($this->pos);
|
$this->inventory = new FurnaceInventory($this->pos);
|
||||||
$this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(
|
$this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(
|
||||||
function(Inventory $unused) : void{
|
static function(Inventory $unused) use ($world, $pos) : void{
|
||||||
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, 1);
|
$world->scheduleDelayedBlockUpdate($pos, 1);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,10 @@ class CraftingManager{
|
|||||||
public function __construct(){
|
public function __construct(){
|
||||||
$this->recipeRegisteredCallbacks = new ObjectSet();
|
$this->recipeRegisteredCallbacks = new ObjectSet();
|
||||||
$this->furnaceRecipeManager = new FurnaceRecipeManager();
|
$this->furnaceRecipeManager = new FurnaceRecipeManager();
|
||||||
$this->furnaceRecipeManager->getRecipeRegisteredCallbacks()->add(function(FurnaceRecipe $recipe) : void{
|
|
||||||
foreach($this->recipeRegisteredCallbacks as $callback){
|
$recipeRegisteredCallbacks = $this->recipeRegisteredCallbacks;
|
||||||
|
$this->furnaceRecipeManager->getRecipeRegisteredCallbacks()->add(static function(FurnaceRecipe $recipe) use ($recipeRegisteredCallbacks) : void{
|
||||||
|
foreach($recipeRegisteredCallbacks as $callback){
|
||||||
$callback();
|
$callback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -447,8 +447,9 @@ class World implements ChunkManager{
|
|||||||
unset($this->generatorRegisteredWorkers[$workerId]);
|
unset($this->generatorRegisteredWorkers[$workerId]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$this->addOnUnloadCallback(function() use ($workerStartHook) : void{
|
$workerPool = $this->workerPool;
|
||||||
$this->workerPool->removeWorkerStartHook($workerStartHook);
|
$this->addOnUnloadCallback(static function() use ($workerPool, $workerStartHook) : void{
|
||||||
|
$workerPool->removeWorkerStartHook($workerStartHook);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user