diff --git a/src/block/tile/BrewingStand.php b/src/block/tile/BrewingStand.php index 8977d36b1..f10c47f79 100644 --- a/src/block/tile/BrewingStand.php +++ b/src/block/tile/BrewingStand.php @@ -54,8 +54,8 @@ class BrewingStand extends Spawnable implements Container, Nameable{ public function __construct(World $world, Vector3 $pos){ parent::__construct($world, $pos); $this->inventory = new BrewingStandInventory($this->pos); - $this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(function(Inventory $unused) : void{ - $this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, 1); + $this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(static function(Inventory $unused) use ($world, $pos) : void{ + $world->scheduleDelayedBlockUpdate($pos, 1); })); } diff --git a/src/block/tile/Furnace.php b/src/block/tile/Furnace.php index bbe9b998b..5f31c8dfb 100644 --- a/src/block/tile/Furnace.php +++ b/src/block/tile/Furnace.php @@ -58,8 +58,8 @@ class Furnace extends Spawnable implements Container, Nameable{ parent::__construct($world, $pos); $this->inventory = new FurnaceInventory($this->pos); $this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange( - function(Inventory $unused) : void{ - $this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, 1); + static function(Inventory $unused) use ($world, $pos) : void{ + $world->scheduleDelayedBlockUpdate($pos, 1); }) ); } diff --git a/src/crafting/CraftingManager.php b/src/crafting/CraftingManager.php index 709480506..50e1cc89a 100644 --- a/src/crafting/CraftingManager.php +++ b/src/crafting/CraftingManager.php @@ -49,8 +49,10 @@ class CraftingManager{ public function __construct(){ $this->recipeRegisteredCallbacks = new ObjectSet(); $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(); } }); diff --git a/src/world/World.php b/src/world/World.php index a0e6ad6d9..081eb1cdb 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -447,8 +447,9 @@ class World implements ChunkManager{ unset($this->generatorRegisteredWorkers[$workerId]); } }); - $this->addOnUnloadCallback(function() use ($workerStartHook) : void{ - $this->workerPool->removeWorkerStartHook($workerStartHook); + $workerPool = $this->workerPool; + $this->addOnUnloadCallback(static function() use ($workerPool, $workerStartHook) : void{ + $workerPool->removeWorkerStartHook($workerStartHook); }); }