for (i = 0; fireArray [i] != undefined && fireArray [i] [0] == true; i++) {
	if (fireArray [i] [0] == true && fireArray [i] [5] > 0) {
		if (fireArray [i] [9] == 7) {fireArray [i] [9] = 6;} if (fireArray [i] [9] == 3) {fireArray [i] [9] = 2;}
		world.setBlockIDAndMetadata(fireArray [i] [1] [0], fireArray [i] [1] [1], fireArray [i] [1] [2], 206, fireArray [i] [9]+1); 
		activeLevel = (fireArray [i] [9] == 6) ? cooking_lvl : smithing_lvl; k = 0;
		for (kk = 0; kk < timeWaited; kk++) {
			fireArray [i] [5] -= 0.05/Math.max(Math.sqrt(activeLevel/45) - 1, 1); j = fireArray [i] [5]; fireArray [i] [4] = 0;
			for (ii = 0; ii < j; ii++) {fireArray [i] [4] += 1; j -= ii;} k += fireArray [i] [4]/(100 - Math.sqrt(activeLevel/10));
		}
		if (fireArray [i] [2] > 0) {
			fireArray [i] [2] -= k;

			if (fireArray [i] [2] <= 0) {//OVERCOOK
				fireArray [i] [7] = fireArray [i] [8];
				if (fireArray [i] [7] != 0 && fireArray [i] [9] == 6) {fireArray [i] [7] = 2023; fireArray [i] [8] = 0;}
				player.dropItem(Item(fireArray [i] [7])); itemSearch = player.getEntitiesWithinRange(0.5);
				for (ii = 0; ii < itemSearch.length; ii++) if (itemSearch[ii].getClassType() == "Item") {
					itemSearch[ii].setPosition(fireArray [i] [1] [0] + 0.5, fireArray [i] [1] [1] + 0.7, fireArray [i] [1] [2] + 0.5);
					fireArray [i] [6] = "0"; fireArray [i] [7] = 0; fireArray [i] [8] = 0; fireHP = 0; fireMaxHP = 0; fireburn = 0;
				}
			}

			if (fireArray [i] [4] > cookMax + Math.sqrt(activeLevel/10) && 
			Math.pow(Math.random()*cookMax,2) < Math.sqrt(fireArray [i] [4] - cookMax)) {//OVERHEAT
				fireArray [i] [7] = fireArray [i] [8]; if (fireArray [i] [9] == 6) {fireArray [i] [7] = 2023;} 
				fireArray [i] [8] = 0; fireArray [i] [2] = 0; fireArray [i] [11] = 0;
				player.dropItem(Item(fireArray [i] [7])); itemSearch = player.getEntitiesWithinRange(0.5);
				for (ii = 0; ii < itemSearch.length; ii++) if (itemSearch[ii].getClassType() == "Item") {
					itemSearch[ii].setPosition(fireArray [i] [1] [0] + 0.5, fireArray [i] [1] [1] + 0.7, fireArray [i] [1] [2] + 0.5);
					fireArray [i] [6] = "0"; fireArray [i] [7] = 0; fireArray [i] [8] = 0; fireHP = 0; fireMaxHP = 0; fireburn = 0;
				}
			}
			
			
		} else {
			fireArray [i] [2] = 0; fireArray [i] [11] = 0; fireArray [i] [7] = fireArray [i] [8];
			if (fireArray [i] [7] != 0 && fireArray [i] [9] == 6) {fireArray [i] [7] = 2023; fireArray [i] [8] = 0;}
		}
	} else {world.setBlockIDAndMetadata(fireArray [i] [1] [0], fireArray [i] [1] [1], fireArray [i] [1] [2], 206, fireArray [i] [9]);}
	if (fireArray [i] [2] + fireArray [i] [3] + fireArray [i] [4] + fireArray [i] [5] + fireArray [i] [8] == 0)
		{fireArray [i] [0] = false;}
}

if (fireArray [actD] != undefined && fireItem.alpha != 0) {
	j = fireArray [actD] [(fireArray [actD] [2] < fireArray [actD] [3]/4) ? 7 : 8];
	if (prices [j] != undefined && prices [j] [0] != undefined)
		{fireItem.u = prices [j] [0] [3]*16; fireItem.v = prices [j] [0] [4]*16; fireItem.texture = prices [j] [0] [5];}
}