148 if($slot < 0 || $slot > 3){
149 throw new \InvalidArgumentException(
"Slot must be in range 0-3");
151 if($time < 0 || $time > $this->getFurnaceType()->getCookDurationTicks()){
152 throw new \InvalidArgumentException(
"CookingTime must be in range 0-" . $this->getFurnaceType()->getCookDurationTicks());
154 $this->cookingTimes[$slot] = $time;
177 if($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){
180 $this->position->getWorld()->addSound($this->position, new BlazeShootSound());
182 }elseif($item->getTypeId() === ItemTypeIds::FLINT_AND_STEEL || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){
183 if($item instanceof Durable){
184 $item->applyDamage(1);
189 }elseif($item instanceof Shovel){
190 $item->applyDamage(1);
195 if($this->position->getWorld()->getServer()->getCraftingManager()->getFurnaceRecipeManager($this->getFurnaceType())->match($item) !==
null){
196 $ingredient = clone $item;
197 $ingredient->setCount(1);
198 if(count($this->inventory->addItem($ingredient)) === 0){
200 $this->position->getWorld()->addSound($this->position,
new ItemFrameAddItemSound());
234 $items = $this->inventory->getContents();
235 $furnaceType = $this->getFurnaceType();
236 $maxCookDuration = $furnaceType->getCookDurationTicks();
237 foreach($items as $slot => $item){
238 $this->setCookingTime($slot, min($maxCookDuration, $this->getCookingTime($slot) + self::UPDATE_INTERVAL_TICKS));
239 if($this->getCookingTime($slot) >= $maxCookDuration){
241 ($recipe = $this->position->getWorld()->getServer()->getCraftingManager()->getFurnaceRecipeManager($furnaceType)->match($item)) instanceof
FurnaceRecipe ?
242 $recipe->getResult() :
248 if ($ev->isCancelled()){
252 $this->inventory->setItem($slot, VanillaItems::AIR());
253 $this->setCookingTime($slot, 0);
254 $this->position->getWorld()->dropItem($this->position->add(0.5, 1, 0.5), $ev->getResult());
257 if(count($items) > 0){
258 $this->position->getWorld()->setBlock($this->position, $this);
260 if(mt_rand(1, 6) === 1){
261 $this->position->getWorld()->addSound($this->position, $furnaceType->getCookSound());
263 $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, self::UPDATE_INTERVAL_TICKS);