@@ -118,7 +118,7 @@ local function furnace_node_timer(pos, elapsed)
118
118
local fuel
119
119
120
120
local update = true
121
- while update do
121
+ while elapsed > 0 and update do
122
122
update = false
123
123
124
124
srclist = inv :get_list (" src" )
@@ -133,13 +133,18 @@ local function furnace_node_timer(pos, elapsed)
133
133
cooked , aftercooked = minetest .get_craft_result ({method = " cooking" , width = 1 , items = srclist })
134
134
cookable = cooked .time ~= 0
135
135
136
+ local el = math.min (elapsed , fuel_totaltime - fuel_time )
137
+ if cookable then -- fuel lasts long enough, adjust el to cooking duration
138
+ el = math.min (el , cooked .time - src_time )
139
+ end
140
+
136
141
-- Check if we have enough fuel to burn
137
142
if fuel_time < fuel_totaltime then
138
143
-- The furnace is currently active and has enough fuel
139
- fuel_time = fuel_time + elapsed
144
+ fuel_time = fuel_time + el
140
145
-- If there is a cookable item then check if it is ready yet
141
146
if cookable then
142
- src_time = src_time + elapsed
147
+ src_time = src_time + el
143
148
if src_time >= cooked .time then
144
149
-- Place result in dst list if possible
145
150
if inv :room_for_item (" dst" , cooked .item ) then
@@ -148,6 +153,9 @@ local function furnace_node_timer(pos, elapsed)
148
153
src_time = src_time - cooked .time
149
154
update = true
150
155
end
156
+ else
157
+ -- Item could not be cooked: probably missing fuel
158
+ update = true
151
159
end
152
160
end
153
161
else
@@ -165,8 +173,7 @@ local function furnace_node_timer(pos, elapsed)
165
173
-- Take fuel from fuel list
166
174
inv :set_stack (" fuel" , 1 , afterfuel .items [1 ])
167
175
update = true
168
- fuel_totaltime = fuel .time + (fuel_time - fuel_totaltime )
169
- src_time = src_time + elapsed
176
+ fuel_totaltime = fuel .time + (fuel_totaltime - fuel_time )
170
177
end
171
178
else
172
179
-- We don't need to get new fuel since there is no cookable item
@@ -176,7 +183,7 @@ local function furnace_node_timer(pos, elapsed)
176
183
fuel_time = 0
177
184
end
178
185
179
- elapsed = 0
186
+ elapsed = elapsed - el
180
187
end
181
188
182
189
if fuel and fuel_totaltime > fuel .time then
0 commit comments