158 if($slot < 0 || $slot > 3){
159 throw new \InvalidArgumentException(
"Slot must be in range 0-3");
161 if($time < 0 || $time > $this->getFurnaceType()->getCookDurationTicks()){
162 throw new \InvalidArgumentException(
"CookingTime must be in range 0-" . $this->getFurnaceType()->getCookDurationTicks());
164 $this->cookingTimes[$slot] = $time;
187 if($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){
190 $this->position->getWorld()->addSound($this->position, new BlazeShootSound());
192 }elseif($item->getTypeId() === ItemTypeIds::FLINT_AND_STEEL || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){
193 if($item instanceof Durable){
194 $item->applyDamage(1);
199 }elseif($item instanceof Shovel){
200 $item->applyDamage(1);
205 if($this->position->getWorld()->getServer()->getCraftingManager()->getFurnaceRecipeManager($this->getFurnaceType())->match($item) !==
null){
206 $ingredient = clone $item;
207 $ingredient->setCount(1);
208 if(count($this->inventory->addItem($ingredient)) === 0){
210 $this->position->getWorld()->addSound($this->position,
new ItemFrameAddItemSound());
244 $items = $this->inventory->getContents();
245 $furnaceType = $this->getFurnaceType();
246 $maxCookDuration = $furnaceType->getCookDurationTicks();
247 foreach($items as $slot => $item){
248 $this->setCookingTime($slot, min($maxCookDuration, $this->getCookingTime($slot) + self::UPDATE_INTERVAL_TICKS));
249 if($this->getCookingTime($slot) >= $maxCookDuration){
251 ($recipe = $this->position->getWorld()->getServer()->getCraftingManager()->getFurnaceRecipeManager($furnaceType)->match($item)) instanceof
FurnaceRecipe ?
252 $recipe->getResult() :
258 if ($ev->isCancelled()){
262 $this->inventory->setItem($slot, VanillaItems::AIR());
263 $this->setCookingTime($slot, 0);
264 $this->position->getWorld()->dropItem($this->position->add(0.5, 1, 0.5), $ev->getResult());
267 if(count($items) > 0){
268 $this->position->getWorld()->setBlock($this->position, $this);
270 if(mt_rand(1, 6) === 1){
271 $this->position->getWorld()->addSound($this->position, $furnaceType->getCookSound());
273 $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, self::UPDATE_INTERVAL_TICKS);