namedtag->BurnTime) or $this->namedtag->BurnTime < 0){ $this->namedtag->BurnTime = 0; } if(!isset($this->namedtag->CookTime) or $this->namedtag->CookTime < 0 or ($this->namedtag->BurnTime === 0 and $this->namedtag->CookTime > 0)){ $this->namedtag->CookTime = 0; } if(!isset($this->namedtag->MaxTime)){ $this->namedtag->MaxTime = $this->namedtag->BurnTime; $this->namedtag->BurnTicks = 0; } if($this->namedtag->BurnTime > 0){ $this->scheduleUpdate(); } } public function onUpdate(){ if($this->closed === true){ return false; } $ret = false; $fuel = $this->getSlot(1); $raw = $this->getSlot(0); $product = $this->getSlot(2); $smelt = $raw->getSmeltItem(); $canSmelt = ($smelt !== false and $raw->getCount() > 0 and (($product->getID() === $smelt->getID() and $product->getDamage() === $smelt->getDamage() and $product->getCount() < $product->getMaxStackSize()) or $product->getID() === Item::AIR)); if($this->namedtag->BurnTime <= 0 and $canSmelt and $fuel->getFuelTime() !== false and $fuel->getCount() > 0){ $this->lastUpdate = microtime(true); $this->namedtag->MaxTime = $this->namedtag->BurnTime = floor($fuel->getFuelTime() * 20); $this->namedtag->BurnTicks = 0; $fuel->setCount($fuel->getCount() - 1); if($fuel->getCount() === 0){ $fuel = Item::get(Item::AIR, 0, 0); } $this->setSlot(1, $fuel, false); $current = $this->getLevel()->getBlock($this); if($current->getID() === Item::FURNACE){ $this->getLevel()->setBlock($this, Block::get(Item::BURNING_FURNACE, $current->getDamage()), true, false, true); } } if($this->namedtag->BurnTime > 0){ $ticks = (microtime(true) - $this->lastUpdate) * 20; $this->namedtag->BurnTime -= $ticks; $this->namedtag->BurnTicks = ceil(($this->namedtag->BurnTime / $this->namedtag->MaxTime) * 200); if($smelt !== false and $canSmelt){ $this->namedtag->CookTime += $ticks; if($this->namedtag->CookTime >= 200){ //10 seconds $product = Item::get($smelt->getID(), $smelt->getDamage(), $product->getCount() + 1); $this->setSlot(2, $product, false); $raw->setCount($raw->getCount() - 1); if($raw->getCount() === 0){ $raw = Item::get(Item::AIR, 0, 0); } $this->setSlot(0, $raw, false); $this->namedtag->CookTime -= 200; } }elseif($this->namedtag->BurnTime <= 0){ $this->namedtag->BurnTime = 0; $this->namedtag->CookTime = 0; $this->namedtag->BurnTicks = 0; }else{ $this->namedtag->CookTime = 0; } $ret = true; }else{ $current = $this->getLevel()->getBlock($this); if($current->getID() === Item::BURNING_FURNACE){ $this->getLevel()->setBlock($this, Block::get(Item::FURNACE, $current->getDamage()), true, false, true); } $this->namedtag->CookTime = 0; $this->namedtag->BurnTime = 0; $this->namedtag->BurnTicks = 0; } $this->server->handle("tile.update", $this); $this->lastUpdate = microtime(true); return $ret; } }