226 if($this->closed ===
true){
230 $this->timings->startTiming();
234 $ingredient = $this->inventory->getIngredient();
237 for($i = 1; $i <= 3; $i++){
238 if($this->inventory->getItem($i)->getId() ===
Item::POTION or
245 if($ingredient->getId() !==
Item::AIR and $ingredient->getCount() > 0){
253 for($i = 1; $i <= 3; $i++){
254 $potion = $this->inventory->getItem($i);
255 $recipe =
Server::getInstance()->getCraftingManager()->matchBrewingRecipe($ingredient, $potion);
256 if($recipe !== null){
268 $this->namedtag->CookTime =
new ShortTag(
"CookTime", $this->namedtag[
"CookTime"] - 1);
270 foreach($this->
getInventory()->getViewers() as $player){
271 $windowId = $player->getWindowId($this->
getInventory());
273 $pk =
new ContainerSetDataPacket();
274 $pk->windowid = $windowId;
276 $pk->value = $this->namedtag[
"CookTime"];
277 $player->dataPacket($pk);
281 if($this->namedtag[
"CookTime"] <= 0){
282 $this->namedtag->CookTime =
new ShortTag(
"CookTime", self::MAX_BREW_TIME);
283 for($i = 1; $i <= 3; $i++){
284 $potion = $this->inventory->getItem($i);
285 $recipe =
Server::getInstance()->getCraftingManager()->matchBrewingRecipe($ingredient, $potion);
286 if($recipe != null and $potion->getId() !==
Item::AIR){
287 $this->inventory->setItem($i, $recipe->getResult());
291 $ingredient->count--;
293 $this->inventory->setIngredient($ingredient);
298 $this->namedtag->CookTime =
new ShortTag(
"CookTime", self::MAX_BREW_TIME);
299 foreach($this->
getInventory()->getViewers() as $player){
300 $windowId = $player->getWindowId($this->
getInventory());
302 $pk =
new ContainerSetDataPacket();
303 $pk->windowid = $windowId;
306 $player->dataPacket($pk);
310 $this->lastUpdate = microtime(
true);
312 $this->timings->stopTiming();