id = Tile::FURNACE; parent::__construct($level, $nbt); if(!isset($this->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->getMetadata() === $smelt->getMetadata() and $product->getCount() < $product->getMaxStackSize()) or $product->getID() === 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(AIR, 0, 0); } $this->setSlot(1, $fuel, false); $current = $this->level->getBlock($this); if($current->getID() === FURNACE){ $this->level->setBlock($this, Block::get(BURNING_FURNACE, $current->getMetadata()), 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->getMetadata(), $product->getCount() + 1); $this->setSlot(2, $product, false); $raw->setCount($raw->getCount() - 1); if($raw->getCount() === 0){ $raw = Item::get(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->level->getBlock($this); if($current->getID() === BURNING_FURNACE){ $this->level->setBlock($this, Block::get(FURNACE, $current->getMetadata()), 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; } }