diff --git a/init.lua b/init.lua index a91bc53..e9fc473 100644 --- a/init.lua +++ b/init.lua @@ -29,6 +29,7 @@ local show_formspec = core.show_formspec local globalstep = core.register_globalstep local on_shutdown = core.register_on_shutdown local get_players = core.get_connected_players +local get_craft_result = core.get_craft_result local translate = minetest.get_translated_string local on_joinplayer = core.register_on_joinplayer local get_all_recipes = core.get_all_craft_recipes @@ -560,6 +561,21 @@ local function get_filtered_items(player, data) return items end +local function get_burntime(item) + return get_craft_result{method = "fuel", items = {item}}.time +end + +local function cache_fuel(item) + local burntime = get_burntime(item) + if burntime > 0 then + fuel_cache[item] = { + type = "fuel", + items = {item}, + burntime = burntime, + } + end +end + local function show_item(def) return def and not (def.groups.not_in_craft_guide == 1 or def.groups.not_in_creative_inventory == 1) and @@ -1514,6 +1530,10 @@ local function get_init_items() if name ~= "" and show_item(def) then cache_drops(name, def.drop) + if not fuel_cache[name] then + cache_fuel(name) + end + if not recipes_cache[name] then cache_recipes(name) end