156 if($slot < 0 || $slot > 3){
157 throw new \InvalidArgumentException(
"Slot must be in range 0-3");
159 if($time < 0 || $time > $this->getFurnaceType()->getCookDurationTicks()){
160 throw new \InvalidArgumentException(
"CookingTime must be in range 0-" . $this->getFurnaceType()->getCookDurationTicks());
162 $this->cookingTimes[$slot] = $time;
185 if($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){
188 $this->position->getWorld()->addSound($this->position, new BlazeShootSound());
190 }elseif($item->getTypeId() === ItemTypeIds::FLINT_AND_STEEL || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){
191 if($item instanceof Durable){
192 $item->applyDamage(1);
197 }elseif($item instanceof Shovel){
198 $item->applyDamage(1);
203 if($this->position->getWorld()->getServer()->getCraftingManager()->getFurnaceRecipeManager($this->getFurnaceType())->match($item) !==
null){
204 $ingredient = clone $item;
205 $ingredient->setCount(1);
206 if(count($this->inventory->addItem($ingredient)) === 0){
208 $this->position->getWorld()->addSound($this->position,
new ItemFrameAddItemSound());
242 $items = $this->inventory->getContents();
243 $furnaceType = $this->getFurnaceType();
244 $maxCookDuration = $furnaceType->getCookDurationTicks();
245 foreach($items as $slot => $item){
246 $this->setCookingTime($slot, min($maxCookDuration, $this->getCookingTime($slot) + self::UPDATE_INTERVAL_TICKS));
247 if($this->getCookingTime($slot) >= $maxCookDuration){
249 ($recipe = $this->position->getWorld()->getServer()->getCraftingManager()->getFurnaceRecipeManager($furnaceType)->match($item)) instanceof
FurnaceRecipe ?
250 $recipe->getResult() :
256 if ($ev->isCancelled()){
260 $this->inventory->setItem($slot, VanillaItems::AIR());
261 $this->setCookingTime($slot, 0);
262 $this->position->getWorld()->dropItem($this->position->add(0.5, 1, 0.5), $ev->getResult());
265 if(count($items) > 0){
266 $this->position->getWorld()->setBlock($this->position, $this);
268 if(mt_rand(1, 6) === 1){
269 $this->position->getWorld()->addSound($this->position, $furnaceType->getCookSound());
271 $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, self::UPDATE_INTERVAL_TICKS);